Add or remove a public key on your Linux instance

To add or replace a key pair

  1. Create a new key pair using the Amazon EC2 console or a third-party tool.
  2. Retrieve the public key from your new key pair. For more information, see Retrieve the public key material.
  3. Connect to your instance using your existing private key.
  4. Using a text editor of your choice, open the .ssh/authorized_keys file on the instance. Paste the public key information from your new key pair underneath the existing public key information. Save the file.
  5. Disconnect from your instance, and test that you can connect to your instance using the new private key file.
  6. (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_keys file.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/replacing-key-pair.html


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *