AWS EC2 SSH:权限被拒绝(publickey)

时间:2014-12-09 16:54:52

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

我已配置我的EC2实例,并使用SSH连接。但是当我创建一个带有端口规则的新安全组时,我再也无法通过SSH访问了。目前,我的自定义安全组规则是:

SSH   0.0.0.0/0
HTTP  0.0.0.0/0
HTTPS 0.0.0.0/0

当我尝试ssh -v -i bodruk.pem ubuntu@ec2-54-149-134-92.us-west-2.compute.amazonaws.com时,出现以下错误:

OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Connecting to ec2-54-149-134-92.us-west-2.compute.amazonaws.com [54.149.
134.92] port 22.
debug1: Connection established.
debug1: identity file bodruk.pem type -1
debug1: identity file bodruk.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubu
ntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000
000
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 e2:13:af:e1:1b:70:f9:70:3b:cd:1d:7f:14:de:ce:90
debug1: Host 'ec2-54-149-134-92.us-west-2.compute.amazonaws.com' is known and ma
tches the ECDSA host key.
debug1: Found key in /c/Users/Thiago/.ssh/known_hosts:2
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: bodruk.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).

已经尝试this solution,但无效。我更改了密钥对两次并删除了 known_hosts 文件但没有成功。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

您可以使用ssh端口telnet到实例吗? (telnet' ip'' port')

如果你可以telnet,那么问题可能出现在密钥对或计算机中。
如果没有,它可能与安全组和网络有关。

答案 1 :(得分:1)

我最近遇到了这个问题,有趣的部分是我的pem文件由root而不是我的用户拥有。当我做了sudo chown user:group {pem file name}时,我能够毫无问题地进行ssh。