#法二 客户端配置 ssh_config
TCPKeepAlive yes
ServerAliveInterval 30
ServerAliveCountMax 86400
#法一 服务端配置 sshd_config
TCPKeepAlive yes
ClientAliveInterval 30
ClientAliveCountMax 86400
重启服务
centos 6: service sshd start
centos 7: /bin/systemctl restart sshd.service
ubuntu: sudo /etc/init.d/ssh restart
mac:
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist