SSH to EC2 Instance

I have been working with AWS (Amazon Web Services) with EC2 (Elastic Computing) instances (Cloud Instances). I had some trouble connecting to them. So I thought of sharing how you could do this in few easy ways.

At the point of creating the instance you can associate an existing key pair or can create one for you. When you create the key file your key will automatically start downloading. Keep that safe and use it to connect. This will have the “pem” extension. Let’s say the file is AWS.pem
  • Linux Shell

This is the easiest way as long as you are on linux or cygwin on windows. Assuming you are connecting to an Ubuntu Server instance.

# using a google IP for demonstration purposes

# Using Elastic IP
ssh -i AWS.pem ubuntu@

# Using Public DNS
ssh -i AWS.pem
  • Using Putty

Pinehead has a nice video explaining everything about using Putty. Only difference is the user name is root. For ubuntu server you can’t connect as root. It’s always “sudo” after connecting using the user “ubuntu”


  • Other

Other commercial tools such as XShell which provides free access for non-commercial/personal/student basis have the support built-in. You can just select the keyfile to use when connecting with the user:ubuntu/root and the Elastic IP/Public DNS