In this tutorial, you will learn to connect to AWS Linux Ec2 instances using putty SSH client through step by step guides.
From a Windows systems, you can connect to an Amazon ec2 Linux instance using putty or the java plugin option provided by AWS. However, The best way to connect to a Linux EC2 instance from Windows is using putty.
Connect to Ec2 Linux Using Putty
Follow the steps given below to SSH in to a Linux ec2 instance from a Windows system using putty utility.
Step 1: Download Putty & Puttygen
First, download putty from here – Download Putty.
You need to download both
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
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
putty.exe and enter the host name or IP (public or elastic IP) as shown in the image 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.
The following table contains the defatul usernames of different AWS AMIs.
|EC2 AMI||Default Username|
|CentOS||centos or ec2-user|
|Fedora||fedora or ec2-user|
|RHEL||ec2-user or root|
|SUSE||ec2-user or 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“.
Common Putty Errors
Following are the common putty errors that you might encounter when trying to connect to ec2 server.
- Authentication with public key “imported-openssh-key” Please login as the user “ec2-user” rather than the user “root”.”
- PuTTY Fatal Error: Disconnected: No supported authentication methods available (server sent: publickey) OK
- Disconnected : No supported authentication methods available (server sent :publickey)
- Connection Timeout Error
Here is what you can do to rectify the above putty ec2 errors.
- Ensure the ec2 instance security group allows port 22 connection from the system you use putty.
- Ensure you are using the correct username of the server. Please check the default username I have listed above in the table.
- Ensure that you are using the correct private key. Sometimes when you copy the private key as text, it might add some extra characters and corrupt the critical file.
- Ensure the corporate proxy allows you to connect to ec2 IP address.
Transfer Files from Windows To Linux
You can tranfer files from Windows to Linux in different ways.
Following are the common ways.
- Using PSCP utiltity
- Using WinSCP
- Using FileZilla FTP client
For detailed steps to transfer files to Linux from Windows, follow the step by step guide on copying file from Windows to Linux.
Putty is available for both Windows & MAC systems. However, it is primarily used in Windows systems to connect to Linux servers over SSH protocol.
Iam getting server refused, while connecting Ubantu ec2 instance using putty.
Please check the ec2 instance security group for port 22 rule.
Thank you so much
Thank you so much!