PuTTY is an SSH and Telnet client, which was developed for the Windows platform by Simon Tatham. Here, in this blog, I will be providing detailed guidance in order to use PuTTY for connecting to the Amazon EC2 instance.
What are the prerequisition before you use PuTTY to connect to your Amazon EC2 instance?
So, before you view this blog, you should have already created your EC2 instance. Also, you should have downloaded ‘putty’ and ‘puttygen’ in your PC. It can be beneficial to obtain knowledge about PuTTY before you dive into the blog.
Hence, for downloading ‘putty’ and ‘puttygen’, and to obtain knowledge about PuTTY you can take reference to my previous blog which has been provided below.
Downloading PuTTY for connecting to Linux based EC2 instances
PuTTY can be handy for connecting to Linux based EC2 instances in Linux. Therefore, in this article, we will be…
Stepwise procedure to connect to Amazon EC2 instance using PuTTY
Step 1: Go to the file location in your PC where you have downloaded the key pair of the Amazon EC2 instance in which you are willing to connect.
The private key file of your EC2 instance allows you to connect to your EC2 instance securely.
Note: If you have not created your Amazon EC2 instance yet, you can go to the link provided below and follow the step till step 15 in order to launch your Amazon EC2 instance.
What is Amazon EC2 and how to launch an EC2 instance: Step by step guide?
Amazon Elastic Cloud Compute (EC2) is a web service that allows you to deploy your applications in the cloud. Amazon…
Step 2: Open ‘puttygen.exe’ and click on the ‘Load’ button.
The ‘.pem’ file which is provided by Amazon is not compatible with PuTTY. So, first of all we are required to convert the file into a compatible format before we use it to connect with SSH. Hence, we have to use ‘puttygen’ to convert the ‘.pem’ file into the compatible format.
Step 3: Here, we are required to import the key pair file. So, first of all, click on the drop on in which ‘PuTTY Private Key Files (*.pkk)’ is selected in default. Now, we need to select ‘All Files (*.*)’ as shown in the image below.
Step 4: Now, your .pem files appear in the file explorer. Select the file and click on the ‘Open’ button.
Step 5: Now, a message dialogue appears which consists of the message as ‘Successfully imported foreign key’. Then, click on the ‘OK’ button. Since we are required to convert the private key of Amazon EC2 into a compatible format for PuTTY, click on the ‘Save private key’ button.
Step 6: After you have clicked on the ‘Save private key’ button, a warning message box appears. Since, we are going to save the key without a passphrase, click on the ‘Yes’ button.
Step 7: Now, provide a suitable name for your PuTTY private key file and click on the ‘Save’ button after you have selected the desired location where you want to save your private key file which is compatible in PuTTY.
Step 8: Here in file explorer we can see that the new private key has been created. So, now you can close the ‘PuTTY Key Generator’.
Step 9: Now, you can open ‘putty.exe’.
Typically, when we connect to SSH we require three things i.e. hostname, a username which we want to connect with and the third one is the authentication file.
Step 10: Let’s get a hostname and username from the AWS EC2 management console. Now, go to the Instances section of AWS from the EC2 Dashboard and click on the ‘Connect’ button after selecting the EC2 instance in which you want to connect.
Step 11: Now, at first copy the hostname of your EC2 instance. For instance: ‘ec2–100–26–170–233.compute-1.amazonaws.com’
Step 12: Paste the hostname in the text field of ‘Host Name (or IP address)’ in the PuTTY Configuration as shown in the image below.
Step 13: Now, copy the username of your EC2 instance. For example: ‘ubuntu’, then in ‘PuTTY Configuration’ on your left-hand side, select ‘Connection’ and then click on ‘Data’. Here, in the text field of ‘Auto-login username’ paste the username of your EC2 instance as shown in the image below. In my case, the username for the EC2 instance is ‘ubuntu’.
Step 14: Finally we have to provide the private key. So, in order to provide the key, go to your ‘PuTTY Configuration’ on your left-hand side, select ‘SSH’, then click on ‘Auth’. Now, click on the ‘Browse’ button.
Step 15: Now, select the converted private key of EC2 instance and click on the ‘Open’ button.
Step 16: You can also save the session in PuTTY. For that, you need to go to your ‘PuTTY Configatrion’ and on your left-hand side, click on ‘Session’. Then, in the text field of ‘Saved Session’, you can provide a suitable name for your session. For example: EC2PuTTySession. Then, click on the ‘Save’ button.
Step 17: Now, click on the ‘Open’ button.
Step 18: After you click on the ‘Open’ button, a ‘PuTTY Security Alert’ dialogue box can appear. Here, since the host is trustable, you can click on the ‘Yes’ button.
Step 19: Finally, you can see that you are now connected to your EC2 instance.