Here are some directives of SSH server’s sshd_config that are related to session timeouts:
Here are some directives of client’s ssh_config:
sshd_config and ssh_config are usually located at /etc/ssh directory of server and client.
These directives are are widely described by man sshd_config and man ssh_config but default settings may be different from distro to distro.
P.S. As for me, I found first tip of current post the most useful as it works brilliantly at every *nix machines I was working with via ssh (just make ping 127.0.0.1 when you’re going to leave ssh terminal untouched for some time).
P.P.S. Another nice workaround is to use screen utility. In case you use it you can be sure that you won’t loose any output of commands you’ve started. Here is little notice how to use it.