向EC2添加新密钥

时间:2011-03-21 00:31:46

标签: amazon-ec2

我现在在Mac上,之前我能够从Windows XP成功设置和访问EC2实例。我想创建一个用于从Mac访问的新密钥,使用控制台管理屏幕生成新密钥,保存PEM文件,仅将文件的权限更改为所有者RW,然后尝试ssh但无法使其工作。这是我的命令

ssh -v -i .ssh/ec2-mac.pem ec2-user@ec2-204-236-143-254.us-west-1.compute.amazonaws.com

这是详细输出

OpenSSH_5.2p1, OpenSSL 0.9.8l 5 Nov 2009
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to ec2-204-236-143-254.us-west-1.compute.amazonaws.com http://204.236.143.254 port 22.
debug1: Connection established.
debug1: identity file .ssh/ec2-mac.pem type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr 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
debug1: Host 'ec2-204-236-143-254.us-west-1.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/bob/.ssh/known_hosts:3
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: /Users/bob/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: .ssh/ec2-mac.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).

任何人都知道我错过了什么?哦,我能够使用为该实例创建的原始密钥进入不同的实例,这使得这更令人费解。

使用chmod 600正确设置权限。我不确定的一件事是在我列出实例时在控制面板管理屏幕中,它只显示“密钥对名称”列中的原始值,是否显示两者?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

您无需为新操作系统创建新密钥。您可以在MAC中使用旧的Windows XP密钥。 另一点是当您使用私钥启动实例时,您只能通过该密钥登录。一把新钥匙无济于事。

此致 Sanket Dangi