Recently, I needed to import my own RSA SSH key to EC2. Here is a quick way to import to all regions

NB: You need the ec2 tools set up before you can run this. You will also need to have setup an x509 certificate pair.

You can read more about the ec2-import-keypair command in the EC2 documentation.

Generate RSA Keypair and SSH into server

First, make sure you have an RSA keypair generated with the ssh-keygen command:

2. It will ask you for a location. Accept the default.

Enter file in which to save the key (/Users/evan/.ssh/id_rsa):

3. Next, it will ask you for a password. Don’t give it one (that is, just hit enter twice):

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

4. Finally, it will tell you that it’s generated the keypair and give you its location. If you’re on Mac OS X, it will also print some ASCII art, in true mac form.

Your identification has been saved in /Users/evan/.ssh/id_rsa.
Your public key has been saved in /Users/evan/.ssh/

5. Now that you have a freshly minted set of crypto credentials, you need to let the servers know about them. This can get tedious. For each server to which you want to authenticate, you’ll need to do the following:

5.1. Upload your key (and type in your password):

5.2. SSH into the server (and type in your password):

5.3. Setup your ~/.ssh folder:

5.4. Logout, login again (without having to type in your password), and log out again:

5.5. Repeat steps 5.1 through 5.4 for each server you’d like to be able to access quickly.

6. Repeat steps 1 through 5.5 on each machine from which you’d be able to access servers quickly.