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, create a new Amazon EC2 Instance(Ubuntu Server 14.04 LTS) and setup Security Groups and open up ports 22, 80 and 443. See Blog: Create a new Instance (Ubuntu 14.04) on AWS EC2 and setup Security Groups
First, find your EC2 instance Public DNS
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.
Step 4: Navigate to Connection/SSH/Auth. Click “Browse” and select the .PPK file you exported from putty gen.
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 'ec2-198-51-100-1.compute-1.amazonaws.com (10.254.142.33)' 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 'ec2-198-51-100-1.compute-1.amazonaws.com' (RSA) to the list of known hosts.