Here's something that I usually forget to change from the default and then get annoyed when my terminal hangs.
- As root open your sshd_config file in an editor.
su -
vim /etc/ssh/sshd_config
- Add the following lines.
ClientAliveInterval 600
ClientAliveCountMax 3
- Restart the sshd process.
service sshd restart
That's it. That will keep you logged in for 30 minutes at a time without activity. (600 seconds x 3)