Friday, December 27, 2013

How To Avoid SSH Time Out While Working On The Command Line

If you’ve worked on the command line for a long time, you would have encountered the session time out problem on more than one occasion. Before you start abusing it though, understand that this brief period of inactivity is good from security point of view. But, it can still be problematic when you are working with operations that take a long time to run. So, in this article, we will discuss how you can avoid the SSH time out problem when working on the command line.


What usually happens to cause the problem is that the connection with the server is reset. So, when the user has been idle for some time, the error produced is ‘Connection reset by peer’. In order to avoid this, we need to use the Keep Alive option on the client or on the server. This gives us two ways to avoid being times out. 

1. Keep Alive Server Side: Server side keep alive is the less secure of the two options. This is because you need to perform an action as root and also because its effect comes on all the client connections and not just your own. Still, if you want to use this method, then here’s how.

- Log in as root

- Edit file at /etc/ssh/sshd_config

- Add this to the file: ClientAliveInterval 60

- Save file

- Restart sshd on the server

2. Keep Alive Client Side: While this method is similar to the Server Side Keep Alive method, it is the more secure of the two. When using Linux, the Client Side method has minor differences to the Server Side method. To use this method,

On Linux:

- Log in as root

- Edit file at /etc/ssh/ssh_config

- Add this to the file: ServerAliveInterval 60

- Save file

On Windows: You have to use PuTTY,

- Open PuTTY

- Click on the Connection Category in the left menu

- Check the box for Enable TCP keepalives (SO_KEEPALIVE option)


No comments:

Post a Comment