Chris Straw

AWS: EC2 Linux Instance – Connect using SSH from your Windows PC

When creating the Instance, select a public subnet if you have a mix of private and public within the VPC.  If not, you will not be able to connect regardless if you enable the public IP

To connect to your Amazon Web Services (AWS) EC2 Linux instance using Secure Shell (SSH) from a Windows machine, you would typically use a program like PuTTY or Windows Subsystem for Linux (WSL). Here’s how you do it with both:

1. Using PuTTY:

Before you start, make sure you have the following:

  • The PuTTY program is installed on your Windows computer. You can download it from the PuTTY website.
  • Your EC2 Instance’s public DNS or public IP address. You can find this on the EC2 console under the “Instances” section.
  • The private key file (.pem) that you got when you launched your instance. If you don’t have this, you won’t be able to connect.

Here are the steps:

  1. Convert your .pem file to a .ppk file that PuTTY can use. You can do this with PuTTYgen, which comes with PuTTY. Just open it, click “Load” to load your .pem file, and then click “Save private key” to save the .ppk version.
  2. Open PuTTY.
  3. In the “Host Name (or IP address)” box, put in ec2-user@your_public_dns or ec2-user@your_public_ip. The ec2-user part is the default user that AWS sets up for you.
  4. In the “Category” list on the left, go to Connection > SSH > Auth.
  5. In the “Private key file for authentication” box, click “Browse” and find the .ppk file you saved earlier.
  6. Go back to the “Session” category and click “Open” to start your SSH session.

2. Using Windows Subsystem for Linux (WSL):

If you’re using WSL, the process is more similar to doing it on a Linux machine. Again, make sure you have your instance’s public DNS or public IP, and your .pem file.

Here are the steps:

  1. Open your WSL terminal.
  2. Navigate to the folder that has your .pem file. For example, if it’s in your Documents folder, you’d use cd /mnt/c/Users/YourUsername/Documents.
  3. Change the permissions of your .pem file so it’s not publicly viewable: chmod 400 your_file.pem.
  4. Connect to your instance with the ssh command: ssh -i your_file.pem ec2-user@your_public_dns or ssh -i your_file.pem ec2-user@your_public_ip.

You should now be connected to your EC2 Linux instance. If you run into any issues, make sure your instance is actually running, that you’re using the right public DNS or public IP, and that your .pem file is correct.

Useful Videos

How to Create a Keypair, Launch, and SSH Into an AWS EC2 Instance

How to create and associate Elastic IP to an EC2 instance