Category: Tutorial

Essentially there is always a few steps to follow in order to easy SSH in to your AWS server without the need for your .pem key. For security reasons, this is not an option when you first setup a server, but with these few instructions, right when you setup your server can save you a lot of irritation always hunting down the correct .pem key.

Pre-Requisites

Must have an AWS Account

Must have a way to use commands line. (PuTTY is an option for windows)

Part 2: Login to your EC2 Server and Add your Key

Next, we will select EC2 and then click on instances. With your instance selected, click on one of the servers and hit connect. It will launch a dialog box with your connection string in there. It should look something like this:

Now grab your connection string and goto command line and past it in. Ex:

$ ssh -i erickey.pem ubuntu@54.215.171.225

Once you're connected to your server, you will need so login into the root user. You will be able to do this by using:

$ sudo su

Next we will cd into our directory with our authorized_keys to add th id_rsa.pub that we have copied to our clipboard. Run:

$ cd ~/.ssh

Here you will see a file called authorized_keys

We need to modify this file by adding our key. Run:

$ nano authorized_keys

and paste your key into the file under the default key at the top. To exit out of the file, hit ctrl+x and then hit y to save the file.

Final

Now you will be able to exit your server and log back in as root just by using

$ ssh root@xxx.xxx.xxx.xx

This makes life a lot easier, so you don't have to hunt down that pesky .pem file and where you put it.