恢复丢失的AWS EC2密钥对 [英] Recovering lost AWS EC2 Key Pairs

查看:216
本文介绍了恢复丢失的AWS EC2密钥对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS新秀在这里.我在我的AWS账户下创建了几个EC2实例,并对所有实例重复使用相同的密钥对.我相信(IIRC)我是从AWS内部生成密钥对的,但这可能是错误的.

AWS rookie here. I created a few EC2 instances under my AWS account and reused the same Key Pair for all of them. I believe (IIRC) that I had generated the Key Pair from inside AWS, but that could be wrong.

在过去的一个周末,我卖掉了旧笔记本电脑(完全擦掉硬盘后),然后又买了一本新笔记本电脑.我现在只是想起(:facepalm ),我忘记了将所有SSH私钥都复制到闪存驱动器中,而我不再拥有它们了.

Over this past weekend I sold my old laptop (after completely wiping the hard disk) and got a new one. I'm just remembering now (:facepalm) that I forgot to copy all my SSH private keys to a flash drive and that I no longer have them.

我想要/需要做的就是将SSH导入我的EC2实例,但是要做到这一点,我需要我的SSH密钥.我仍然具有AWS控制台访问权限,并且可以登录并查看所有的EC2密钥对.但是我看不到任何用于下载它们或使用新的密钥对更新我的EC2实例的选项.

All I want/need to do is to SSH into my EC2 instances, but to do that I need my SSH keys. I still have AWS console access, and I can log in and view all my EC2 Key Pairs. But I don't see any options for downloading them or updating my EC2 instances with new Key Pairs.

所以我问:

  1. 我能否以某种方式恢复我现有的密钥对,以便可以通过SSH进入我的EC2实例?同样,我可以登录到AWS控制台.如果不是,那么...
  2. 是否可以生成另一个密钥对并为我现有的密钥对交换"?

我真的不想拆掉旧的EC2实例并重新配置新的EC2实例,这将花费大约一周的时间(尽管可以说,它将为我服务!).

I really don't want to have to tear down my old EC2 instances and re-provision new ones, that will take about a week for me to do (although, arguably, it would serve me right!).

推荐答案

重建不应该是必需的.身份证建议选项2,因为它更快,更容易.

Rebuild shouldnt be nesserary. Id suggest option 2 as its quicker and easier.

1.>是否可以更改/附加新密钥?

1.> Its possible to change/append a new key?

  • 关闭要访问的ec2实例(目标")的电源.

  • Power off the ec2 instance you want to access ("target").

创建一个新的(临时")实例.

Create a new ("temporary") instance.

从目标实例分离主要EBS卷(注意其当前附件!).

Detach the primary EBS volume from target instance (taking note of its current attachment!).

在临时实例上附加/挂载目标卷.

Attach/mount target volume on temporary instance.

在已安装的卷上编辑适当的authorized_keys文件.

edit appropriate authorized_keys file on the mounted volume.

卸载目标卷,然后重新连接到目标ec2实例(使用在拆卸时记下的配置)

unmount target volume, and reattach to target ec2 instance (using config you noted when detatching it)

启动目标实例并使用新密钥登录.

start target instance and login with new key.

删除临时实例

2.>是的.快照实例.从快照中配置一个新实例,并选择其他密钥(在启动向导结束时单击启动时,会显示密钥对弹出窗口)

2.> Yes. Snapshot the instance. Provision a new instance from the snapshot selecting a different key (keypair popup appears when you click launch at end of launch wizard)

这篇关于恢复丢失的AWS EC2密钥对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆