使用 ubuntu@ SSH 到 aws 权限被拒绝(公钥)为什么会失败?

标签 ssh amazon-web-services ssh-keys

尽管我通常对 github 或 heroku 没有任何问题,但我似乎无法使用 SSH 连接到 AWS。调试如下,我试过@ubuntu 和@ec2-user(应该是@ubuntu),我也试过在.ssh 中创建一个配置文件(在windows 上)并添加'ChallengeResponseAuthentication yes',因为那似乎在另一个线程上修复它,但没有运气。我已将 .pem 文件的权限修改为 400。我不明白为什么它说这一切听起来都是积极的但随后失败了,如果我能更好地了解错误是什么,我可能会找到解决方案.非常感谢任何帮助!

$ ssh -v -i futurebot2.pem ubuntu@ec2-54-218-75-37.us-west-2.compute.amazonaws.com
OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/Mark/.ssh/config
debug1: Connecting to ec2-54-218-75-37.us-west-2.compute.amazonaws.com [54.218.75.37] port 22.
debug1: Connection established.
debug1: identity file futurebot2.pem type -1
debug1: identity file futurebot2.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA f2:cd:94:4d:a1:9a:b5:67:cb:f7:91:d7:ef:4d:a4:3d
debug1: Host 'ec2-54-218-75-37.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/Mark/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: futurebot2.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

最佳答案

这可能发生的两个原因。

  • 用户不存在,这可能是由于连接了错误的用户或不是您自己的实例(错误的 IP 地址)
  • 用户的授权 key 文件中没有您的 key 。在 AWS 中,您在启动时选择的 key 会添加到您的实例中,但如果您想使用其他 key ,则需要将它们添加到您的 authorized_keys 中。手动归档。
  • 关于使用 ubuntu@ SSH 到 aws 权限被拒绝(公钥)为什么会失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17286782/

    相关文章:

    使用子流程的 Python 自动化

    http - 如何在 Go 中为来自同一个监听器的 SSH 和 HTTP(S) 流量提供服务?

    java - JSch : SSH_MSG_DISCONNECT: 11 Internal server error 的 SFTP 连接错误

    amazon-web-services - 如何从使用 CloudFormation 部署的自动化文档在 EC2 实例中执行 bash 代码

    angular - AWS API Gateway 资源中的 "Enable CORS"?

    github - 使用 SCP 通过 SSH 从 github 复制文件

    mysql - Rails 何时使用 BEGIN 和 COMMIT 包装插入?

    git - 将 git 配置从 Windows 移动到 Ubuntu

    git - SSH 在 Windows 上查找公钥/私钥对的错误位置

    linux - 使用 cgi-perl 脚本的无密码 SSH