In this tutorial, you will learn to connect to AWS Linux Ec2 instances using the Putty SSH client through step by step guides.
From a Windows system, 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 into a Linux ec2 instance from a Windows system using the putty utility.
Step 1: Download Putty & Puttygen
First, 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 putty gen
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 the ec2 Instance using SSH client putty
Open putty.exe
and enter the hostname 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 default usernames of different AWS AMIs.
EC2 AMI | Default Username |
---|---|
Ubuntu | ubuntu |
Debian | admin |
CentOS | centos or ec2-user |
Fedora | fedora or ec2-user |
RHEL | ec2-user or root |
SUSE | ec2-user or root |
Oracle | ec2-user |
Bitnami | bitnami |
Now go 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 username 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 the 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: public key) OK
- Disconnected: No supported authentication methods available (server sent:public key)
- 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 the ec2 IP address.
Transfer Files from Windows To Linux
You can transfer files from Windows to Linux in different ways.
Following are the common ways.
- Using PSCP utility
- Using WinSCP
- Using FileZilla FTP client
For detailed steps to transfer files to Linux from Windows, follow the step-by-step guide on copying files from Windows to Linux.
Conclusion
Putty is available for both Windows & MAC systems. However, it is primarily used in Windows systems to connect to Linux servers over SSH protocol.
9 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
Thank you so much!