亚马逊网络服务-无法使用发送给我的私钥连接到AWS EC2(权限被拒绝:公钥)



我知道这是一个常见的问题,但我相信我的情况并非常见。

我有一个ubuntu AWS EC2实例,我使用mac上的私钥访问它。

我想在工作时访问,所以我把密钥放在我的dropbox帐户中,并将其下载到我的工作(windows(pc上,放在C:/Users/[myusername]/.ssh目录中。我也喜欢chmod 600

我将Gitshell用于ssh,因为它有ssh,我现在不想安装putty。

所以我运行命令

C:Users[myusername].ssh> ssh -v -i .key_pair.pem ubuntu@[redacted].compute.amazonaws.com

(当然要使用正确的dns名称。(

这是输出:

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to [redacted].compute.amazonaws.com [[redacted]] port 22.
debug1: Connection established.
debug1: identity file .\key_pair.pem type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 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
Warning: Permanently added '[redacted].compute.amazonaws.com,[redacted]' (RSA) to the list of known hosts.
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: Offering public key: C:\Users\[myusername]\.ssh\github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: .\key_pair.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).

我确信我使用的密钥是正确的,因为它在我的Mac上工作。还有什么我做错了吗?

编辑:我注意到调试输出提到:

debug1: Offering public key: C:\Users\[myusername]\.ssh\github_rsa

它提供一个不相关的公钥这一事实是否会影响身份验证?

.key_pair.pem错误。

./key_pair.pem与Gitbash一起使用(无论您是否在windows上(

最新更新