amazon-web-services - AWS SSH 连接错误 : Permission denied (publickey)

标签 amazon-web-services ssh amazon-ec2 ssh-keys

我正在尝试使用 SSH 连接到我的 EC2 实例,但我快疯了。我已阅读这篇文章并尝试了所有用户组合:

AWS ssh access 'Permission denied (publickey)' issue

它仍然不适合我。知道我错过了什么吗?

  roberto@ubuntu:~/keys$ ssh -v -i ec2-key-pair.pem ec2-user@ec2-54-72-242-0.eu-west-1.compute.amazonaws.com
OpenSSH_6.6, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-54-72-242-0.eu-west-1.compute.amazonaws.com [54.72.242.0] port 22.
debug1: Connection established.
debug1: identity file ec2-key-pair.pem type -1
debug1: identity file ec2-key-pair.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6p1 Ubuntu-2ubuntu1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA e4:06:ee:a5:a5:d2:97:5f:0f:b7:06:5e:f2:b3:da:26
debug1: Host 'ec2-54-72-242-0.eu-west-1.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/roberto/.ssh/known_hosts:3
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: ec2-key-pair.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

UPDATE: 

根据@aldanux建议:

    roberto@ubuntu:~/keys$ ssh-keygen -R 54.72.242.0
# Host 54.72.242.0 found: line 4 type ECDSA
/home/roberto/.ssh/known_hosts updated.
Original contents retained as /home/roberto/.ssh/known_hosts.old
roberto@ubuntu:~/keys$ ssh -i ec2-key-pair.pem ec2-user@ec2-54-72-242-0.eu-west-1.compute.amazonaws.com
Warning: Permanently added the ECDSA host key for IP address '54.72.242.0' to the list of known hosts.
Permission denied (publickey).

最佳答案

您可能以错误的用户身份登录。如果它是 Ubuntu 实例,命令将是:

ssh -v -i ec2-key-pair.pem ubuntu@ec2-54-72-242-0.eu-west-1.compute.amazonaws.com

关于amazon-web-services - AWS SSH 连接错误 : Permission denied (publickey),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23392763/

相关文章:

security - 其他 EC2 用户网络可以嗅探我的流量吗?

amazon-web-services - Kubernetes 中的 NGINX 无法解析 DNS

amazon-web-services - 为什么 S3 对象的 ETag 会在副本下更改?

python - 如何通过子进程模块调用 ssh 以便它使用 SSH_ASKPASS 变量

security - 为什么SSH不使用互锁协议(protocol)?

amazon-web-services - AWS 控制台和 cli 有所不同。哪个值得信赖?

python - Boto3 - 打印 AWS 实例平均 CPU 利用率

mysql - 带有 MySQL 的 AWS Ubuntu 服务器

amazon-web-services - 使用 CloudFormation 添加对 AWS websocket API 的集成响应

linux - SSH 守护进程 (NIO2) 不再启动