To add or replace a key pair
- Create a new key pair using the Amazon EC2 console or a third-party tool.
 - Retrieve the public key from your new key pair. For more information, see Retrieve the public key material.
 - Connect to your instance using your existing private key.
 - Using a text editor of your choice, open the 
.ssh/authorized_keysfile on the instance. Paste the public key information from your new key pair underneath the existing public key information. Save the file. - Disconnect from your instance, and test that you can connect to your instance using the new private key file.
 - (Optional) If you’re replacing an existing key pair, connect to your instance and delete the public key information for the original key pair from the 
.ssh/authorized_keysfile. 
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/replacing-key-pair.html
Leave a Reply