Amazon EC2 上次因为某个漏洞大面积重启,我的小instance也不可避免。之后因为想做深度神经网络,我也创建了一个GPU的instance, 但是当时发现怎么都无法SSH上去。因为当时也只是随便试试,所以以为是ubuntu或者instance的问题就没有重视。结果今天发现一直host 我的网站的那个instance也无法SSH上去了。 不论怎么修改pem 或者ppk文件的权限,都只是看到Access Denied (Public Key) 错误。 所以决定换用一个Key,准备使用网上别人研究出来的detach volumne的办法。方法如下:
Here is what I did, thanks to Eric Hammond's blog post:
- Stop the running EC2 instance
- Detach its
/dev/sda1volume (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_keysto/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
.pemfile
等我今晚试一试。
前几天写的上面的步骤,今晚试了一下,最后成功了。一开始先开了一个新的instance但是SSH不进去,后来发现好像是因为新的instance启动成功之后initialization还没有完成我就试图去SSH。但是当时不知道,所以就Terminate掉它,以为是旧的pem文件有问题,就重新创建了一个key pair, 然后再创建了一个新instance,等它彻底initialize完了,再SSH就成功了。
有几点心得:
1)要等新的instance启动完以后自检结束在尝试用SSH连进去;
2)要先用sudo去创建/mnt/tmp文件夹,然后再mount。
mount 一个卷的命令是 mount /dev/xvdf /mnt/tmp

被折叠的 条评论
为什么被折叠?



