Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (12.9k points)

I was given AWS Console access to an account with 2 instances running that I cannot shut down (in production). I would, however, like to gain SSH access to these instances, is it possible to create a new Keypair and apply it to the instances so I can SSH in? Obtaining the existing pem file for the keypair the instances were created under is currently not an option.

If this isn't possible is there some other way I can get into the instances?

1 Answer

0 votes
by (18.2k points)

According to official AWS documentation, there is a way to can regain access to your instance if you have lost your key pair, which I think might be helpful in your case.

Try the following steps to change key pair for your EC2 instance.

Step 1: Stop your instance

Step 2: Detach the EBS volume from your instance

Step 3: Launch a new instance and create a key pair for this instance.

Step 4: Attach the same EBS volume that you detached from your original instance to the newly launched instance.

Step 5: Modify the authorized key file as shown below:

copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys

Step 6: Detach this volume and then attach it back to your original instance

Step 6: Restart your original instance

Step 7: Use the new key pair to connect and login to your original instance.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories

...