Select your connection, load it
In the left-hand menu pane, select Connection
In the field beside Seconds between keepalives, enter 5.
Check Enable TCP Keepalives (SO_KEEPALIVE option)
Now click Open and leave the SSH connection idle for a while to see if it stays up.
If you are using a PuTTY session profile, don’t forget to Save your profile with these new settings.