A guide to connecting to EC2 Instances with secret keys

This is a quick tutorial and more of an additional information for my Cloud For Dummies article on EC2 .

Assuming that you have followed the article above and successfully created a web server with EC2 , let’s see how you can access the webserver via SSH to do better things.

While AWS Console is a powerful tool , there is still a lot of things that you cannot achieve with the console itself .

It’s a pain to put it straight .

Some situations that really need for a remote connection

  1. Imagine you have to tweak a file that’s on the server . It’s not possible for you to do it with console .
  2. You want to install a specific service let’s say a LAMP stack , upgrade python , install nginx

Let’s see how you can connect to the EC2 instance .

Before we start , remember the secret key that you downloaded ( a PEM file ) upon creating the EC2 instance . We need that before we proceed further.

If you are using a Windows machine follow the steps below.

  1. If you are using Git Bash then you can follow the steps follows under the Linux section

2. If you are using Putty then let’s start

Assuming that you have Putty already installed let’s first convert the PEM file to PPK .( Remember the extra step for PUTTY )

Follow the link below to convert a PEM to PPK , as PUTTY doesnt works with PEM files

3. Now we need to load the PPK key into PUTTY as follows.

4. Once then select the session and provide the details of your EC2-Instance IP and hit load . Alternatively you can also save the session and load later . You might have to change the IP if your EC2-Instance is not running on static IP.

5. You should now see a terminal window with the prompt as follows

6. Enter ec2-user and proceed and you should get the EC2 prompt as follows.

If you are using a Linux machine follow the steps below.

  1. Open the terminal and locate the directory where your pem keys are located

2. Fire the command

When you hit enter , you should get the following prompt

3. Type yes and press enter and you should get the following prompt.

4. If you don’t get it check the Security Group settings that I have suggested which need to be updated to allow SSH ( port 22 ) connections from your IP .

5. Now you are remotely connected to your EC2-Instance and can proceed with firing commands directly into your EC-instance.

Thank You.

Cloud Architect , Pythonista , Polyglot