连接到EC2实例时出错

时间:2012-03-31 15:44:30

标签: ssh amazon-ec2

这是日志:

macs-MacBook-Air:~ mac$ ssh -v -i sohoKey.pem ec2-user@ec2-107-22-101-75.compute-1.amazonaws.com 
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to ec2-107-22-101-75.compute-1.amazonaws.com [107.22.101.75] port 22.
debug1: Connection established.
debug1: identity file sohoKey.pem type -1
debug1: identity file sohoKey.pem-cert 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.6
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-107-22-101-75.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/mac/.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: 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: Offering RSA public key: sohoKey.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: sohoKey.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).

在AWS控制台中,我看到我的密钥对已被删除。我创建了一个同名的新的。然后我尝试连接ssh -v -i sohoKey.pem ec2-user@ec2-107-22-101-75.compute-1.amazonaws.com

3 个答案:

答案 0 :(得分:2)

创建一个具有相同名称的密钥对将无济于事 - 这是其中的数据。

也无法更改正在运行的实例上的密钥对,我不相信您可以做任何事情。如果您要从实例中恢复数据并且该卷是EBS卷,则可以将该卷标记为在终止时不被删除。终止实例后,卷应保持不变,您将能够将其附加到其他实例。

答案 1 :(得分:1)

您可以尝试启动一个新实例,然后将存储与丢失密钥对的存储断开连接,然后将其添加到新实例。

另一个选项,但我还没试过,是从当前实例创建一个新图像。完成后,创建新图像的新实例并创建新的密钥对。

无论哪种方式,你都失去了连接的能力,你不能为一个实例添加一个新的密钥对(据我所知)。

答案 2 :(得分:0)

我从实例中分离了我的EBS卷。之后我创建了一个新实例,然后将8GB EBS附加到该实例上。

之后,我将该实例挂载到/ mybackup。

所以我可以从/ mybackup /...

获取我的数据

感谢您的建议。

但我仍然不知道,为什么我的钥匙对已经消失了?

相关问题