亚马逊云科技 - 在 AWS 实例上生成了新的 SSH 密钥,现在我被锁定(无法通过 SSH 进行 SSH)



我在aws实例上有一个ssh密钥(我们称之为密钥a(;但是,它不允许我访问github帐户,所以我生成了一个新的ssh密钥(密钥b(。好的是我能够访问github,但坏的是我现在不能通过ssh访问我的aws实例。

知道我能做什么吗?我尝试更改pem文件的权限,但没有成功。我在aws上远程运行ubuntu 12.04,在windows机器上本地运行。

附加信息:当我创建密钥b并将其命名为rsa\id.pub时,我没有有意或明确地覆盖密钥a。我尝试了两种语法,ssh(我的默认语法(和ssh-i xxx.pemubuntu@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).

如果您的实例是EBS备份的(而且应该是(,那么一切都不会丢失。您可以将实例移动到机器上,并在此过程中设置一个新密钥:

http://blog.celingest.com/en/2013/11/14/replace-lost-keypair-ec2-instance/

这里缺少两条重要信息:

  • 你是创建了一个新密钥,还是覆盖了现有的密钥(在本地机器上(

  • 您尝试ssh的具体程度如何,也就是说,ssh的确切语法是什么?

假设你生成了一个新的密钥来访问你的github帐户,这不应该影响你现有的AWS实例的密钥对。你应该按照的路线运行一些东西

ssh -i /path/to/key.pem ubuntu@your-public-dns-name 

此外,您应该确保您的密钥文件具有适当的权限。

最新更新