Replace ssh key of the AWS EC2 machine

You can follow the below steps to change the SSH key for a AWS EC2 machine.

Step 1)

Check that you have existing ssh key working and we can log in to the machine using it. You can also directly login via a new function in AWS console.

Step 2)

Generate a new SSH key via Amazon Web Console

Step 3)

Get the public key from it. Using the command below

ssh-keygen -y -f ~/Downloads/second.pem

If working on Windows system using this https://www.puttygen.com/convert-pem-to-ppk


Step 4)

Login to the machine and edit the file.

vi ~/.ssh/authorized_keys

Add the new public key and check that you are able to login with the new key

Step 5)

Change permission of new key to 400 and try to login

Step 6)

If login is successful delete the old key from authorized keys file


No comments:

Post a Comment

Please share your views and comments below.

Thank You.