I have seen several questions and answers about changing the EC2 key pair for a running instance. However I am a complete AWS newbie at this point and I can easily stop the
Change key pair in AWS Ec2 instance.
Sometimes it's necessary to change the private key for some security reason. We can able to change the private key or key pair while running the Ec2 instances.
In the case of changing the private key pair, we need to enter the SSH using the below command.
• Chmod 400 key.pem • Ssh user @ip-ikey.pem
Example: ssh ubuntu@108.23.68.92-itest.pam
Change the existing key pair
ssh-keygen
The created private key will be restored in /home/user/.ssh/id_rsa
, and the public key will be stored in /home/user/.ssh/id_rsa.pub
.
Then copy the public key from id_rsa.pub file to /home/user/.ssh/authorized_ key file
.
The next step is to copy the private key which named as “id_rsa” in the file and then recreate the new file name it as (try. pem) in the local system.
Connect to Ec2 instance by using the recently created private key.
chmod 400 try.pem
ssh Ubuntu@ip –I try.pem
Start your instance by using the private key. enter link description here