The initial version of putty is dated back to January 8, 1999, and was designed for the 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, but it does offer a beautiful Terminal interface.
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 purpose of the article is to discuss putty let’s 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 straightforward as with any other normal windows installation. At the time of writing this article, the current version of putty is 0.78.
[ Recommended Read: How to Install PuTTY on Linux ]
Some utilities 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 keys.
- 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, you will see a dialog box that controls everything we can do with putty. Configuring sessions and related parameters are pretty easy in putty through this dialog box.
Let us now explore some important options from the dialog box.
Connect to Remote Linux Using Putty
To connect to any remote servers via SSH we will use either an 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, and Serial. Most of the time we will use either a 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 server’s host key in the Windows registry so it can verify against the key whenever we log in to the server and throws a warning in case of a change in the 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 a ‘Connection reset by peer’ error because 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 you with a username and password. Instead of typing the 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, read Configure “No Password SSH Keys Authentication” with PuTTY on Linux.
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 of 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 in 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, we can 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 that 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 when we might need to connect to multiple sessions or restart the current session or duplicate the current session. Right-click from the 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
A telnet connection can be established when we use the connection type “Telnet”. By default, port 23 is taken, and 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?
The session and its related information are stored in the windows registry (HKEY_CURRENT_USER\SOFTWARE\SimonTatham). We can export the session and import it into a different machine to retain the configurations.
To export session-related information, from the windows cmd prompt:
regedit /e "%USERPROFILE%\Desktop\.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
To export all settings, from the 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 the GUI interface putty also allows users to do various things from the 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
This article has seen how to install and configure various supported protocols, command-line options, and some alternatives to putty.