【问题标题】:Permission denied (publickey) while accessing aws through ssh通过 ssh 访问 aws 时权限被拒绝(公钥)
【发布时间】:2017-07-08 04:48:29
【问题描述】:

我正在尝试通过 ssh 从我的 PC 连接到我的 ec-2 free(t2.micro) 实例。

我已经使用默认 VPC 创建了实例。我无法从我的电脑连接它。

它向我抛出权限被拒绝错误。

我已经检查了安全组中的规则。

我已经通过以下网址检查答案但没有成功。

AWS SSH connection error: Permission denied (publickey)

Troubleshooting Connecting to Your Instance

SSH: Permission denied (publickey)

当我在命令下运行时

sudo ssh -v -i tep-keyPair.pem ubuntu@ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com

出现以下错误:

OpenSSH_7.3p1, LibreSSL 2.4.1
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: Connecting to ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com [52.XX.XXX.XX] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file tep-keyPair.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file tep-keyPair.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256                 SHA256:ZeJ4XQUfgLkaMUEvjGohL/6FWKN9Gq4AXrPwL/i9t3M
debug1: Host 'ec2-52-XX-XXX-XX.us-west-2.compute.amazonaws.com' is  known and matches the ECDSA host key.
debug1: Found key in /var/root/.ssh/known_hosts:3
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: tep-keyPair.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

请帮帮我..我真的被困在这里了

【问题讨论】:

  • 您是否检查过安全组是否允许 0.0.0.0 的端口 22 SSH 的传入连接?

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


【解决方案1】:

您收到Permission denied (publickey) 错误表明您正在与实例成功通信,因此问题与网络或安全组无关。

相反,实例不接受通过您提供的密钥对的连接。因此,您要么需要为其提供所需的密钥对,要么可以将新的密钥对复制到实例

要将不同的密钥对复制到实例,请按照 StackOverflow 答案中的说明进行操作,该答案是为 Ubuntu 编写的:Change key pair for ec2 instance

【讨论】:

    猜你喜欢
    • 2016-09-19
    • 2016-09-24
    • 2018-11-06
    • 2010-11-30
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    相关资源
    最近更新 更多