To set the timout for a SSH connection with a host, insert the following line into the file /etc/ssh/sshd_config:
ClientAliveInterval 60 ClientAliveCountMax 10
This sets a timout of 10 minutes (10 * 60 seconds).
After this changes you have to restart the ssh daemon
sudo service sshd restart