简体   繁体   English

无法访问 EC2 实例

[英]Lost access to EC2 instance

I reformatted my macbook and completely forgot to copy my ~/.ssh directory.我重新格式化了我的 macbook,完全忘记了复制我的~/.ssh目录。

I tried ssh'ing into my EC2 instance我尝试通过 ssh 进入我的 EC2 实例

$ 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?但我认为它不起作用,因为我的 PEM 文件链接到旧笔记本电脑上的 id_rsa 文件?

I had the PEM file in my google drive.我的谷歌驱动器中有 PEM 文件。

I've tried我试过了

  • sudo chmod 400 xxx.pem
  • Update my security group to allow SSH access to my new laptop更新我的安全组以允许 SSH 访问我的新笔记本电脑

Any ideas how I can regain access to my EC2 insance?有什么想法可以让我重新获得对我的 EC2 实例的访问权限吗?

I would generate a new key pair as explain here , but it requires me to have access to the instance我会按照此处的说明生成一个新的密钥对,但这需要我能够访问该实例

Update: check @jordanm comment.更新:检查@jordanm 评论。 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.如果您的实例没有附加弹性 IP,则您可能已经更改了外部 IP。

  1. Login to AWS Console登录AWS 控制台
  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 . Select 您的 EC2 实例在列表中,在左上角 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. (可选)如果一切就绪,请考虑使用控制台终止原始实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM