Connect to AWS EC2 Instance via Putty/SSH

For connecting to your AWS EC2 instance, you can do it via Putty (for Windows user) or via SSH (for Linux/Mac user).

Assuming that you have created an AWS EC2 Instance and Key Pair (.pem file) is locally available for connection. If not then you can follow our below posts to complete these prerequisites.

First, find your EC2 instance Public DNS

Connect to AWS EC2 Instance via SSH_1

For Windows Users

Step1: Download Putty and putty gen from here

Step 2: Use putty gen to convert .PEM file to .PPK file. See Blog: How to convert .PEM file to .PPK file using putty gen

Step 3: Launch Putty and enter the host IP address and set the port to 22.

Connect to AWS EC2 Instance via SSH_2

Step 4: Navigate to Connection/SSH/Auth. Click “Browse” and select the .PPK file you exported from putty gen.

Connect to AWS EC2 Instance via SSH_3

For Mac/Linux users

Step 1: Use the chmod command to make sure your private key file isn’t publicly viewable. For example, if the name of your private key file is my-key-pair.pem, use the following command:

chmod 400 /path/my-key-pair.pem

Step 2: Use the ssh command to connect to the instance. You’ll specify the private key (.pem) file and user_name@public_dns_name.
Example:- For Ubuntu, the username is ubuntu. For Fedora, the user name is either fedora or ec2-user.

ssh -i /path/my-key-pair.pem <EC2 user name>@Public_DNS_Name

You’ll see a response like the following.

The authenticity of host ' ('
can't be established.
RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f.
Are you sure you want to continue connecting (yes/no)?

Step 3: Enter yes and You’ll see a response like the following.

Warning: Permanently added '' (RSA) 
to the list of known hosts.