server 设置
(1)编辑 /etc/ssh/sshd_config
修改 ClientAliveInterval
和 ClientAliveCountMax
:
# 表示server向client请求消息的时间间隔
# 默认是0,不发送,单位为“秒”
ClientAliveInterval 600
# client 没有响应 server 的次数
# 达到后就自动断开
ClientAliveCountMax 300
重启 ssh 服务:
$ service sshd restart
(2)编辑 /etc/profile
添加:
TMOUT=0
生效:
$ source /etc/profile
client 设置
~/.ssh/config
中添加:
Host *
ServerAliveInterval 60
来源:oschina
链接:https://my.oschina.net/yogoup/blog/3166930