Putty is an opensource terminal emulator that supports several network protocols like Telnet, SSH, Rlogin, SCP, and Raw Socket.
The initial version of putty is dated back to January 8, 1999, and designed for Windows Operating system but now it is supporting other operating systems like macOS and Linux too. But I have never seen people using Putty in Linux or macOS because it ships with beautiful Terminal.
There are many more alternatives available but each has its pros and cons. You can play with different options and let us know which serves the best.
Since the sole of the article is to discuss putty lets jump into it right away. The context of this article is created under Windows 10 environment.
Go to the official putty site to download the binary and install it. Installation is pretty straight forward as like any other normal windows installation. At the time of writing this article, the current version of putty is 0.74.
There are some utilities that come with the installation and we will see their uses.
- PUTTY – SSH and Telnet client.
- PSCP – Command-line utility to copy files securely.
- PSFTP – general file transfer sessions much like FTP
- PUTTYGEN – Utility to generate RSA and DSA key.
- PLINK – Command Line interface to putty back ends.
- PAGEANT – Authentication agent for Putty, PSCP, PSFTP, and Plink.
You can also download these utilities as standalone binaries.
How to Start and Use Putty SSH Client
When we launch putty first thing you will see is a dialog box that controls everything that we can do with putty. Configuring session and related parameters are pretty easy in putty through this dialog box.
Let us now explore some important options from the dialog box.
Remote Server Connection
To connect to any remote servers via SSH we will use either IP address or FQDN (Fully qualified domain name). By default, SSH is bonded to port 22 unless the SSH port was changed.
There are 4 connection types available RAW, Telnet, Rlogin, SSH, Serial. Most of the time we will use either Telnet or SSH connection.
We can also configure our sessions and save them. This allows us to reopen our session with all the configurations retained.
You will get an alert as displayed in the below image either when you connect with the server for the first time or when the SSH protocol version is upgraded. Putty registers the host key of the server in the Windows registry so it can verify against the key whenever we log in to the server and throws warning in case of a change in host key. This is one of the features of the SSH protocol to prevent any network attack.
Enable Wrap Mode on Putty
When a long line of text reaches the end of the right-hand window, it will wrap over the next line. To use this feature, we need to select the checkbox “Auto wrap mode initially on”. If Wrap Mode is set to
off will it create a horizontal scrollbar? well, no. It simply will not display the lines that are greater than the length of the page.
NOTE: This setting can also be changed in the middle of an established session which will be taken into immediate effect.
Increase Window Scroll Buffer Size
There is a limitation on how many lines of text putty keeps. When you are working with very large files or trying to display log files putty only keeps a few lines of it in windows buffer for us to scroll back and see. To increase the scrollback buffer size, we can increase the value “Lines of scrollback”.
You can also change some behaviors when the window is resized like changing the size of the font.
Enable SSH Keep Alive Time
There might be situations where you will encounter ‘Connection reset by peer’ error because of our session is idle for a long time. In such a case, the connection will be closed by the network devices or firewalls assuming the session is completed.
We can set keepalives so null packets will be sent to prevent connection drop. Values mentioned in Keepalives are measured in Seconds. Keepalives are supported only in Telnet and SSH.
Enable Auto SSH Login with Username
Whenever you connect to a session it will prompt with username and password. Instead of typing username every time you can set the user name under Login details.
You can also configure your session for password less login using SSH (Public & Private) key authentication. To know more about generating and configuring password less login take a look at this article.
Customize Window Title
By default, putty will display “hostname – PuTTY” as a window title name. We can override this option by setting a new title under “Window title”.
We can use “Alt-Enter” to toggle to Full-Screen mode but before that, we have to enable this feature. Select the tick box as shown in the image.
Customize Putty Terminal Appearance
You can change the color scheme and appearance of the putty terminal. There are some nice collections of color schemes for putty in GitHub.
Change the appearance like font, font size, cursor appearance, etc.
Enable Rich Text Format
Enabling this option allows the copied text to be stored in the “Rich Text Format” in the clipboard. Whenever we copy and paste the content to any word processor the colors, format, the style will remain the same as in PuTTY.
Enable Putty Logging
Logging is an important feature in putty. We can store our session output to a text file which can be viewed later for a different purpose.
Points to Note:
- You can control what should be logged through the “Session logging” option. In my case, I am capturing all of my session output.
- If the log file already exists in the given path then we can either overwrite or append the logs.
- Date and Time options are available to format the log file name which is very handy.
Now I tried connecting to a remote machine which is running Linux Mint 19 and storing the output locally. Whatever I type in my terminal, its output is captured in session logs.
There might be times where we might need to connect to multiple sessions or restart the current session or duplicate the current session. Right-click from putty title bar where we have options to start/restart/duplicate sessions. We can also change the settings for the current session from the “Change Settings…” option.
Putty Telnet Session
Telnet connection can be established when we use connection type as “Telnet”. By default, port 23 is taken, different ports can also be used to check if ports are opened or not.
Export and Import Putty Sessions
In the previous section, we discussed how to connect and configure a session. Now, where does this session information is stored?
Session and its related information are stored in the windows registry (HKEY_CURRENT_USER\SOFTWARE\SimonTatham). We can export the session and can import it in a different machine to retain the configurations.
To export session related information, from windows cmd prompt:
regedit /e "%USERPROFILE%\Desktop\.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
To export all settings, from windows cmd prompt:
regedit /e "%USERPROFILE%\Desktop\<Name of your file>.reg” HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
To import settings, either you can double click the
.reg file or import it from cmd prompt.
Putty Command Line
Apart from GUI interface putty also allows users to do various things from cmd prompt (Windows). Below are a few of the useful commands.
Establish an SSH connection:
putty.exe -ssh <IP ADDRESS (OR) FQDN>:22/
Establish a Telnet connection:
putty.exe telnet:<IP ADDRESS (OR) FQDN>:23/
Note: Syntax between SSH and Telnet command differs.
To load the saved session:
putty.exe -load “session name”
-i - Specify the name of private key file -x or -X - X11 Forwarding -pw - Password -p - Port number -l - Login name -v - Increase verbose -L and -R - Port forwarding
In this article, we have seen how to install and configure, various supported protocols, command-line options, and some alternatives to putty.