即使 PEM 文件丢失,如何访问 EC2 实例 [英] How to access EC2 Instance even if PEM file is lost

查看:21
本文介绍了即使 PEM 文件丢失,如何访问 EC2 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我丢失了 EC2 实例的 PEM 密钥.我遵循了以下所有步骤:

I lost the PEM key to the EC2 Instance. I followed all the following steps:

即使 PEM 文件丢失,如何访问 EC2 实例

即使您丢失了 pem 文件,访问 EC2 实例也相当容易.

Accessing the EC2 instance even if you loose the pem file is rather easy.

  1. 首先,通过创建新的访问文件来创建一个新实例,将其命名为helper"实例,其区域和 VPC 与丢失的 pem 文件实例相同.

  1. First, create a new instance by creating new access file, call it 'helper' instance with same region and VPC as of the lost pem file instance.

现在停止丢失的 pem 文件实例.记住不要终止实例而是停止它.

Now stop the lost pem file instance. Remember not to terminate instance but to stop it.

转到 EBS 卷,选择丢失的 pem 文件实例的根卷并分离.

Go to EBS volumes, select the root volume of the lost pem file instance and detach.

现在再次选择分离的卷,这次您必须将此卷附加到我们之前创建的帮助程序实例.由于辅助实例默认已经有一个根卷为/dev/sda1,所以新附加的卷将是次要的(例如:/dev/sdf).

Now again select the detached volume and this time you have to attach this volume to helper instance which we created before. Since helper instance already has a root volume by default as /dev/sda1, the newly attached volume will be secondary(eg: /dev/sdf).

使用其 pem 文件登录您的帮助程序实例.

Login to your helper instance with its pem file.

执行以下命令:

# mount /dev/xvdf1 /mnt
# cp /root/.ssh/authorized_keys /mnt/root/.ssh/
# umount /mnt

  • 从帮助程序实例中分离辅助卷.

  • Detach the secondary volume from helper instance.

    再次将卷附加回我们的恢复实例.启动实例.终止帮助程序实例.

    Again attach the volume back to our recovery instance. Start the instance. Terminate the helper instance.

    使用辅助实例 pem 文件登录恢复实例.

    Use helper instance pem file to log into recovery instance.

    推荐答案

    很高兴看到您的答案.仅供参考,AWS 也为此分享了他们的官方教程,因此在此处分享相同内容:https://youtu.be/F8jXE-_hdfg

    Great to see your answers. Just for the information AWS has shared their official tutorial also for the same hence sharing the same here: https://youtu.be/F8jXE-_hdfg

    通过这个视频我们可以发现,AWS 支持一直从用户那里得到同样的问题,因此制作了具有详细结构的东西.

    With this video we can found, AWS support has been getting this same questions from the users and hence made this stuff with detailed structure.

    这是一步一步的细节.希望这可以帮助.

    This is with step by step details. Hope this helps.

    这篇关于即使 PEM 文件丢失,如何访问 EC2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆