编辑配置文件 ~/.ssh/config
加入以下配置项,如不存在新建一个即可:
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
编辑配置文件 /etc/ssh/sshd_config
,取消掉其中以下两项的注释:
ClientAliveInterval 300
ClientAliveCountMax 2
原文:https://www.cnblogs.com/gebilaowangpython/p/10418035.html