For users who use putty.exe to connect to ssh can use the following setting in Putty to keep the session live.

Putty -> Change Settings -> Connection

putty keepalive

Putty keepalive

Change the value of seconds between keep alive based upon your requirements.