无法连接到Amazon EC2:权限被拒绝(公钥)

时间:2014-06-06 12:41:27

标签: ssh amazon-ec2

我对Amazon EC2感到有些失落。我刚刚创建了一个实例并生成了一对密钥。我将它保存在我的win7硬盘上。

我通过终端开始了一个ssh连接:

$ ssh -v -i EC2.pem instance_id@ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com [54.76.160.55] port 22.
debug1: Connection established.
debug1: identity file EC2.pem type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6p1 Ubuntu-2ubuntu1
debug1: match: OpenSSH_6.6p1 Ubuntu-2ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/FLE/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
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: EC2.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).

似乎不想让我进去。

当我尝试使用putty时,它会回答Disconnected: No supported authentication methods available

这是什么?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

不知道您尝试ssh的确切实例类型,但格式应为“userid@ec2host.com” - 您似乎正在使用实例ID。应该看起来像这样:

ssh -i my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com

ec2-user是Amazon Linux的默认用户,ubuntu是所有ubuntu实例输入器的默认用户。

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html