【发布时间】:2014-06-17 10:16:51
【问题描述】:
我在 aws 实例上有一个 ssh 密钥(我们称之为密钥 a);但是,它不允许我访问我的 github 帐户,所以我生成了一个新的 ssh 密钥(密钥 b)。好事是我能够访问 github,但坏事是我现在无法通过 ssh 访问我的 aws 实例。
知道我能做什么吗?我尝试更改 pem 文件的权限无济于事。我在aws上远程运行ubuntu 12.04,在本地运行windows机器。
附加信息:当我创建密钥 b 并将其命名为 rsa_id.pub 时,我并没有有意或明确地覆盖密钥 a。我尝试了两种语法,ssh(我的默认)和 ssh -i xxx.pem ubuntu@ec2-xxx-xx-xxx-x.compute-1.amazonaws.com。这些语法都不起作用。
OpenSSH_6.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/xx/.ssh/config
debug1: /home/xx/.ssh/config line 1: Applying options for awshost1
debug1: Connecting to ec2-xx-xxx-xxx-xx.us-west-2.compute.amazonaws.com [54.201.134.83] port 22.
debug1: Connection established.
debug1: identity file /home/xx/.ssh/xx.pem type -1
debug1: identity file /home/xx/.ssh/xx.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.4
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_5*
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
debug1: Host 'ec2-xx-xxx-xxx-xx.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/xx/.ssh/known_hosts:1
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: /home/xx/.ssh/xx.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).
【问题讨论】:
-
一经设置,始终在 S3 上创建服务器快照。这样一来,您就可以从 AWS 数据中心的硬件故障到更改 SSH 密钥等任何事情中恢复。