Intellipaat Back

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

How do I change the key pair for my ec2 instance in AWS management console? I can stop the instance, I can create new key pair, but I don't see any link to modify the instance's key pair.

1 Answer

0 votes
by (18.2k points)
You can follow the below-mentioned steps to change the key pair for your EC2 instance.

Note: The following procedure is valid for EBS backed instances only.

step 1: Stop your EC2 instance

Step 2: Unmount and detach the EBS volume from your instance

Step 3: Attach this EBS volume to another newly instance with new key pair.

Step 4: Modify the authorised key file as shown below:

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

Step 5: Detach this volume and attache it back to the original instance

Step 6: Restart the original instance

Step 7: Connect and login to your original instance using the new key pair.

Related questions

Want to get 50% Hike on your Salary?

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

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...