modify
/etc/ssh/ssh_config
add this configuration
Host *
ServerAliveInterval 100
modify
/etc/ssh/sshd_config
then add this configuration
ClientAliveInterval 60
TCPKeepAlive yes
ClientAliveCountMax 10000
Finally restart the ssh server
service ssh restart or service sshd restart