From a Windows machine, you can connect to an Amazon Linux instance using putty or the java plugin option provided by Amazon. The best way to connect to a Linux EC2 instance is using putty.
In this tutorial, I will explain how to connect an EC2 instance using putty software.
Step 1: Download putty
Download putty from here – Download Putty.
You need to download both puttygen.exe
and putty.exe
.
The key file you download from the AWS console will be a .pem file. Since putty uses .ppk file extensions for authentication, you need puttygen to convert the .pem file to .ppk format.
Step 2: Convert .pem to .ppk using puttygen
Open puttygen.exe
and load the .pem
private key you downloaded when you created the ec2 instance.
It looks like“example.pem
“. Once you open the .pem file a pop-up window will appear, asking you to save the private key. Click ok and click the save private key button.
Save the .ppk file in any folder.
Note: Do not click generate a key or any other buttons. Just load the pem file and click the save the private key button.
Step 3: Connect to ec2 Instance using SSH client putty.
Open putty.exe
and enter the host name or IP (public or elastic IP) as shown in the figure below.
Eg: “ec4-50-18-154-285.compute-1.amazonaws.com” or if you have given an elastic IP for your instance, then you should enter that elastic IP in the host field.
Now go to connection–>data and type in the user name.
username
differs for different instance types.
- For Ubuntu the default user name is ubuntu
- For RHEL and Amazon Linux instance the default user name is ec2-user
- For SUSE instance the default user name is a root
Now got to SSH–>Auth click on Auth and load the .ppk file you generated using puttygen.
Click open. The connection will be established.
You don’t have to give any user name or password because the connection will be established using the private key.
If you get any errors while connecting, leave a comment below. The figure shown below is a connection established using the username “ubuntu“.
3 comments
Hi,
Iam getting server refused, while connecting Ubantu ec2 instance using putty.
Please check the ec2 instance security group for port 22 rule.
Great instructions,
Thank you so much