0 votes
1 view
in AWS by (8.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.5k 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.
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...