无法访问EC2实例 [英] Lost access to EC2 instance
问题描述
我重新格式化了Macbook,却完全忘了复制我的〜/.ssh
目录.
I reformatted my macbook and completely forgot to copy my ~/.ssh
directory.
我尝试将ssh'ing进入我的EC2实例
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
但是我认为它不起作用,因为我的PEM文件已链接到旧笔记本电脑上的id_rsa文件吗?
But I presume it's not working because my PEM file is linked to the id_rsa file on my old laptop?
我的Google驱动器中有PEM文件.
I had the PEM file in my google drive.
我尝试过
-
sudo chmod 400 xxx.pem
- 更新我的安全组以允许SSH访问到我的新笔记本电脑上
有什么想法可以重新获得EC2保险?
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
推荐答案
更新:检查@jordanm注释.您没有与该实例的连接,也许不需要创建一个新实例.
Update: check @jordanm comment. You have no connection to the instance, maybe there is no need to create a new one.
据我所知,只有一种方法可以创建一个新方法.如果您对现有实例进行映像,则可以保留数据.如果您的实例未连接弹性IP,则可能已更改了外部IP.
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.
- 登录到 AWS控制台
- 创建一个新的密钥对.
- 在列表中选择您的EC2实例,在左上角选择
Actions->.图像和模板->创建图像
.填写表格以创建图像. - 使用您创建的图像和新密钥启动新实例.
- (可选)如果一切就绪,请考虑使用控制台终止原始实例.
- Login to AWS Console
- Create a new key pair.
- 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. - Launch a new instance using the image you've created and your new key.
- (optional) If everything is in place consider terminating the original instance using console.
这篇关于无法访问EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!