Lost access to EC2 instance

99封情书 提交于 2021-01-29 15:31:07

问题


I reformatted my macbook and completely forgot to copy my ~/.ssh directory.

I tried ssh'ing into my EC2 instance

$ ssh ec2-user@xx.xxx.xxx.xx -i xxx.pem -v
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to xx.xxx.xxx.xx [xx.xxx.xxx.xx] port 22.
debug1: connect to address xx.xxx.xxx.xx port 22: Operation timed out
ssh: connect to host xx.xxx.xxx.xx port 22: Operation timed out

But I presume it's not working because my PEM file is linked to the id_rsa file on my old laptop?

I had the PEM file in my google drive.

I've tried

  • sudo chmod 400 xxx.pem
  • Update my security group to allow SSH access to my new laptop

Any ideas how I can regain access to my EC2 insance?

I would generate a new key pair as explain here, but it requires me to have access to the instance


回答1:


Update: check @jordanm comment. You have no connection to the instance, maybe there is no need to create a new one.

As far as I know there is only way to create a new one. You can keep data if you make an image of your existing instance. You may have changed external IP if your instance has no elastic IP attached.

  1. Login to AWS Console
  2. Create a new key pair.
  3. Select your EC2 instance in the list, in the top-left corner select Actions -> Image and templates -> Create image. Fill the form to create an image.
  4. Launch a new instance using the image you've created and your new key.
  5. (optional) If everything is in place consider terminating the original instance using console.


来源:https://stackoverflow.com/questions/65721493/lost-access-to-ec2-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!