Add this to /etc/ssh/sshd_config:
/etc/ssh/sshd_config
KeepAlive yes ClientAliveInterval 30 ClientAliveCountMax 999999