i always face with this problem every time i use ssh client from new installed debian system. Edit the /etc/ssh/sshd_config


ClientAliveInterval 300
ClientAliveCountMax 10

On client side, in $HOME/.ssh/config or /etc/ssh/ssh_config

ServerAliveInterval 30
ServerAliveCountMax 10

Make sure the ssh server using Protocol 2
Check man ssh_config and sshd_config for more info