Wednesday, March 15, 2017

Install and configure PuTTY for making SSH connections

Being able to securely connect to remote hosts from windows using SSH is a very important and common requirement, especially when you are working with remote linux servers. SSH is a high-security protocol. It uses strong encryption to shield your connection from eavesdropping. capture, and other sorts of attack. In this post we will discuss exactly how to do this using PuTTY tool. We will also show how to create and save PuTTY sessions and discuss how to configure login without password using key pair.

PuTTY is a free, open source SSH client and a terminal emulator for windows. It has a very easy to use user interface and the ability to configure and store sessions, so that we can connect to configured hosts in a single click.

For the sake of this illustration, let us assume that we need to connect to a remote linux host with the domain name abc.xyz.comWe will assume that we the userid is user1 and password is password

Many times, you might have to use a keypair to logon to the remote host, instead of using userid and password. This is the case when you are using AWS. To elaborate this case, we will assume you have the key pair MyKey.pem saved to C;\temp\MyKey.pem and we will discuss how to configure that in PuTTY as well.

Step 1 - Download and install PuTTY

Let us download putty from http://www.putty.org/ and install

Step 2 - Convert .pem file to .ppk file. (You can skip this step if you are using userid and password)

If your key pair is in a .pem file, before you can use it with PuTTY to login, we should extract the private key from the .pem file, to a format that is understood by PuTTY(which is a .ppk file). This can be done using the puttygen.exe, which will be available in C:\Program Files (x86)\PuTTY location once you complete the PuTTY installation.

Run the puttygen.exe by double clicking the file and load the .pem file by clicking the "Load" button

Once you import the file, you will see something like picture below.

Now you can export the private key to a .ppk file by clickng the "Save private key" button. If you want to protect the key with a passphrase, provide the password on the prompt, else leave it blank. Let us assume you have saved the private key to "MyKey.ppk"

Step forward in 2017: Build in-demand career skills with Coursera
Step 3 - Configure PuTTY session

Now open PuTTY, by searching for it in the Start menu (Windows + S). It is not a bad idea to pin PuTTY to the task bar if you need to access it very frequently. You will see the below screen.

1) Enter the dns name or the IP address of the server to connect to.


2) (Optional) Let us set a window title so that we can identify the shell window, if there are multiple PuTTY sessions going on


3) (Optional) Let us disable automatic change of window title once login is complete


4) If using userid/password for login, you can avoid being prompted for userid, by configuring it to the session

Else if you are using key pair to login, specify the key pair as below


5) Now let us save this session configuration to a meaningful name, so that it is easy to open this session with just a single click in future

Step 4 - Load the PuTTY session and connect 

Now to open an SSH connection, all you need to do is to select the session you want to launch and click the "Load" button and then "Open" button



And now you should be connected to your host via SSH.



Blog Archive