If you work on remote Linux servers often, then you’re probably already familiar with PuTTY.
PuTTY is a free terminal emulator, network file transfer application, and serial console for the Windows platform. Offering support for many different network protocols, like SSH, SCP, Telnet, raw socket connection, and rlogin, it is one of the most popular Windows connection clients. It is developed as open-source software by a group of volunteers.
The Problem
By default, PuTTY sessions are not configured to “stay/keep alive” (more on that below). And SSH servers usually have a timeout value.
So, when you SSH into a server via PuTTY and are inactive for a while, if your period of inactivity exceeds the SSH sever’s timeout value, your PuTTY session will automatically end without your knowledge.
When you eventually return to PuTTY and try to execute a command, you will be greeted with the following error message:
Network error: Software caused connection abort
Now, you have to login again and make sure you remain active. Otherwise, there will be another timeout.
This is annoying!
Yes, you could technically tweak your SSH server to never timeout. But why change a server-wide setting like that for just one client? And those server settings are usually quite complicated. Trust me.
Besides, in most cases, as a client, you probably don’t have the permissions needed to tweak SSH server settings.
A much better option would be to have PuTTY somehow figure it out.
How To Make Sure Your PuTTY Session Never Times Out
The idea behind the following solution is to make PuTTY keep sending null packets (called “keepalives”) to the remote server, tricking the server into thinking that the session is alive, forcing it to keep the connection open.
Step 1: Create A Session Profile
Create a PuTTY session profile like you normally would. I’m not bothering to go into the details of that here. The most important fields are Host Name (or IP address), Port, and Connection Type. Save your new session.
Step 2: Configure The Session Profile With “KeepAlives”
With your new session loaded, click Connection on the left side pane and you will see a screen like this:
Notice the field labelled Seconds between keepalives (0 to turn off).
Change this value to some other value. 10 or 15 should be okay. This value represents the time interval between two null packets sent to the remote server to keep the session alive.
The assumption here (and a reasonable assumption too) is that your SSH server can stay idle for more than 10 or 15 seconds without timing out (some servers may use a default timeout as low as 5 seconds or as high as 2 hours).
If your session continues to timeout after setting PuTTY keepalives to say 15 seconds, set the value to a lower number.
Step 3: Save The Session Profile
On the left pane, click on Session. This action takes you back to the window in Step 1.
Assuming you’re already working with a named, saved, and loaded session, just press Save again to save your keepalive setting to this session.
You should be ready to go now.
To access the profile in the future and make use of it without unnecessary timeouts, select the session you’ve just created in the “Saved Sessions” list and click Open.
Leave a Reply