Find sshd_config (oftenly located in /etc/ssh), uncomment these lines, and chnage the values:

ClientAliveCountMax 120
ClientAliveInterval 15
TCPKeepAlive yes

Then restart the service:

sudo service sshd restart