I had this strange problem of mac terminal connection loss frequently anytime I connected to a remote server. I know there is a setting in Putty (on windows) to alter SSH Keep Alive time which prevents frequent disconnect from servers.
On Mac OS X, simply open /etc/ssh/ssh_config and add below at the last line
vi /etc/ssh/ssh_config ServerAliveInterval 10
This will allow terminal to send a null packet to connected server every 10 seconds and will stop mac terminal session from disconnecting 👍👍👍