更改密钥对EC2实例 [英] Change key pair for ec2 instance
本文介绍了更改密钥对EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何更改密钥对在AWS管理控制台我的EC2实例?我可以停止实例,我可以创建新的密钥对,但我没有看到任何一个环节修改实例的密钥对。
How do I change the key pair for my ec2 instance in AWS management console? I can stop the instance, I can create new key pair, but I don't see any link to modify the instance's key pair.
推荐答案
下面是我做的,感谢埃里克·哈蒙德的博客文章:
Here is what I did, thanks to Eric Hammond's blog post:
- 停止正在运行的EC2实例
- 在分离了
的/ dev / sda1的
体积(姑且称之为容积A) - 在开始新的t1.micro EC2实例,用我的新的密钥对
- 附加卷A到新的微实例,如
的/ dev / xvdf
(或的/ dev / SDF
) - SSH到新的微实例,并安装卷A到
的/ mnt / tmp目录
- 复制
的〜/ .ssh / authorized_keys中
到/mnt/tmp/home/ubuntu/.ssh/authorized_keys
- 注销
- 终止微实例
- 从它分离容积A
- 附加卷了一回主实例作为
的/ dev / sda1的
- 启动主实例
- 在登录和以前一样,使用新的
质子交换膜
文件
- Stop the running EC2 instance
- Detach its
/dev/sda1
volume (let's call it volume A) - Start new t1.micro EC2 instance, using my new key pair
- Attach volume A to the new micro instance, as
/dev/xvdf
(or/dev/sdf
) - SSH to the new micro instance and mount volume A to
/mnt/tmp
- Copy
~/.ssh/authorized_keys
to/mnt/tmp/home/ubuntu/.ssh/authorized_keys
- Logout
- Terminate micro instance
- Detach volume A from it
- Attach volume A back to the main instance as
/dev/sda1
- Start the main instance
- Login as before, using your new
.pem
file
就是这样。
这篇关于更改密钥对EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文