By using this site you agree to the use of cookies.

Learn more

Share via:

Connect to EC2 Instances With SSH

How to connect to Amazon EC2 instances via SSH.

Edited: 2017-03-30 18:33

You can connect to EC2 with SSH to remote control your server, install updates, and do other maintenance work. You would also use SSH when installing a web server, such as Apache.

When first connecting, it is important that your key file has the right permissions. This is often a problem when connecting from a Linux terminal, because people simply forget about it. If you are either connecting for the first time, or have moved your file since last time, then you may need to change the permissions. This is easy:

sudo chmod 400 /home/YourUserName/keyfiles/YourKeyFile.pem

Another common problem when connecting, is that we forget our username for EC2. When we connect to the server, we should append the Public DNS with ubuntu@. Example below:

ssh -i /home/YourUserName/keyfiles/YourKeyFile.pem ubuntu@ec2-10-0-0-1.compute-1.amazonaws.com

The Public DNS part in the above is the part after the @, and it will be different for your server. If you do not know the Public DNS of your server, you can easily find it by logging into your account on aws.amazon.com

If these instructions are unclear, you can also watch the video embedded last in the tutorial. Note that there may be minor differences in the AWS website, if it has been updated since the video was recorded.

Connecting via SSH from Windows

If you are on Windows, you will need to either use the build-in SSH capabilities (Linux services for Windows), or use a program, such as Putty, to connect.

The procedure should be the same as the above, and you will be able to perform the same actions after logging in.

You can get the latest version of Putty here: http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Video