Client configuration
Try creating the file: ~/.ssh/config
Add the contents:123Host * ServerAliveInterval 30 ServerAliveCountMax 5
Server configuration
Edit configuration file: /etc/ssh/sshd_config12ClientAliveInterval 20ClientAliveCountMax 5