If you create your own key pair using the command line, follow the recommendations at create-key-pair or New-EC2KeyPair Cmdlet for key type and bit length. If you create your own key pair using a third-party tool, be sure that your key matches the guidelines at Importing Your Own Public Key to Amazon EC2.
Learn how to easily generate and add a new public and private key pair to an AWS EC2 instance. This is useful if you ever need to replace a compromised key or provide ssh access to multiple users without sharing private keys.
1. Generate a New Private Key
- Login to the AWS EC2 console and select
Key Pairs
in the left sidebar - On the next page, click the
Create Key Pair
button - Give the new key a name, then click the
create
button - Download the new key, and then
chmod
it to 0666
For this tutorial we’ll call this new private key
NewKey.pem
2. Generate a New Public Key
Next, use
NewKey.pem
that was created in step 1 to create a new public key. The new public key will be NewKey.pub
.