The following configuration will prevent an SSH session to terminate automatically upon long time of inactivity:

File: ~/.ssh/config
Content:
Host *
Protocol 2
TCPKeepAlive yes
ServerAliveInterval 60
StrictHostKeyChecking = no