For an explanation of the following ssh_config options see http://linux.die.net/man/5/ssh_config
Configuring the server
Edit /etc/ssh/ssh_config
sudo vim /etc/ssh/ssh_config
Add the following lines
ClientAliveInterval 15
ClientAliveCountMax 4
ClientAliveCountMax 4
And restart the SSH server for the changes to take affect
/etc/init.d/ssh restart
Configuring the client
Edit vim ~/.ssh/config
sudo vim ~/.ssh/config
Add the following lines so connections to all Hosts have the same SSH options
Host * ServerAliveInterval 15 ServerAliveCountMax 4
Security consideration
Keeping a SSH connection permanently open could be a security issue.
To explicitly close an inactive connection after 60 seconds set the ServerAliveInterval/ClientAliveInterval to 60, and the ServerAliveCountMax/ClientAliveCountMax to 0
*AliveInterval 60
*AliveCountMax 0
The above was tested using:
Server
- Ubuntu 10.04 Lucid Lynx
Client
- Ubuntu 11.04 Natty Narwhal
No comments:
Post a Comment