====== Keeping Your ssh Sessions Alive ====== You might notice that when use the terminal to ssh to a remote host, if you stay inactive for too long, your connection will expire, leaving you with an unresponsive prompt... You have been disconnected! This can also be observed when you choose to mount a remote server from within the Desktop environment: {{ :tricks:mate:connect-to-server-menu.png?direct&200 |}} {{ :tricks:mate:connect-to-server-ssh.png?direct&200 |}} After a few minutes, the connected server's windows will become unresponsive. ==== ssh Session Timeout ==== This is due to the fact that, for obvious security reasons, most remote systems will timeout any inactive ssh session after a short time. How annoying for power users like us! ==== Choose Your Level ==== The solution to avoid this is to have your ssh session sending a "ServerAlive" signal on a regular basis, telling the remote system you're still there. The timeout between signals sent can be controled with the ServerAliveInterval parameter, it can be set at three different levels: * Global level: will affect all ssh sessions made from your system * User level: will affect all ssh sessions initiated by a specific user * Host level: will a specific ssh session timeout per host, for a specific user === Global === To modify the **global** session timeout on your system, edit the /etc/ssh_config file: <code> sudo nano /etc/ssh/ssh_config </code> and add this line at the end of the file (if it does not already contain the ServerAliveInterval directive): <code> ServerAliveInterval 60 </code> === Per User === To modify a **user**'s session timeout, edit the /home/<username>/.ssh/config file <code> [sudo] nano /home/<username>/.ssh/config </code> Add this line (or modify the existing one if any): <code> Host * ServerAliveInterval 60 </code> Please note that the second line is indented with a space! === Per Host === You could determine **per host** intervals by specifying their name in /home/<username>/.ssh/config : <code> Host *hostname.tld ServerAliveInterval 60 </code>