How to prevent SSH from disconnecting sessions


If you work with SSH, you already know that, after few minutes of inactivity, a session would be closed automatically, for security reasons. In fact, you could have forgotten to shut it down, and someone could take control of your system. But, if you think it’s not your problem, you can change this behaviour in your GNU/Linux configuration. The following commands must be executed from SSH client.

How to stop SSH from disconnecting

The following steps needs to be performed in your SSH client, not in the remote server.

First of all, open your text editor and modify your current user config file, which is located at:


Add the following lines:

Host *
 ServerAliveInterval 60

ensuring that the second line will start with a space.

The first line, tells SSH to apply this configuration for all remote hosts. Of course, you can specify just one of them, changing ‘*’ with the desired host.

After you did this, you need to apply the above settings:

sudo source ~/.ssh/config

To apply this settings globally, add or modify the following line in /etc/ssh/ssh_config file.

ServerAliveInterval 60

Save and close the file.

In this way, your SSH session will not be closed for inactivity.


Remember that the security of your system, expecially in server case, is not secondary, and that is all in your hand. Changing the behaviour of programs like SSH must be done only if you know exactly what you want, and after being sure that this will not put you in some problem.


  1. Have you constantly cashed in big money without trading in anything or rather left out taking almost any mlm marketing kind of work and not have to make investments any-thing. I want to inform you of a job in which almost all resources is certainly given to you and additionally it is an easy and really simple work. Without requiring to design your very own domains and many more., all are going to be provided to you without any expense. Customers will explore your web site therefore you will benefit from getting paid for that. It really is as easy as that. I am creating lots of money from home through this work exactly like $20000 a month or higher if also you really want to earn like that then follow here relatively easy instruction manuals by checking out this internet website >>>>> GOCHIURL.COM/15csr


Please enter your comment!
Please enter your name here