【问题标题】:AWS EC2 SSH: Permission denied (publickey)AWS EC2 SSH:权限被拒绝(公钥)
【发布时间】:2015-11-11 05:19:47
【问题描述】:

我已经配置了我的 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 文件,但没有成功。

有什么想法吗?

【问题讨论】:

  • 您能提供更多信息吗?您是否能够使用不同的安全组进行 ssh 访问?创建一个新的安全组是如何阻止你 ssh 进入的?您的实例是否与密钥对关联?
  • 我为 SSH 或 All Trafic 尝试了不同的安全组规则,但都不起作用。我会尝试删除实例并重新设置。
  • 您是说它适用于一种安全组配置,但不适用于上面列出的一种?安全组只会阻止流量,它们不会影响流量本身。您是否将规则放在 Inbound 或 Outbound(应该是 Inbound)上?
  • @JohnR 我删除了我的旧实例并生成了一个新实例。现在一切正常。谢谢。

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


【解决方案1】:

你能用 ssh 端口远程登录到实例吗? (telnet 'ip' '端口')

如果可以telnet,那么问题可能出在Key Pair 或您的计算机上。
如果不是,它可能与安全组和网络有关。

【讨论】:

  • 我删除了我的旧实例并生成了一个新实例。一切正常。谢谢!
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2014-07-24
    • 2016-09-19
    • 1970-01-01
    • 2017-03-24
    • 2018-11-15
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    相关资源
    最近更新 更多