ssh连贯超时的解决办法

设置ssh超时工夫的办法。

这个应该是在server端批改
批改本人 root 目录下的.bash_profile文件,加上
export TMOUT=1000000 (以秒为单位)
而后运行:

source .bash_profile
在/etc/ssh/sshd_config中退出:
ClientAliveInterval=60
每一分钟,sshd都和ssh client打个招呼,检测它是否存在,不存时即断开连接。

留神:设置实现后,要退出ssh近程连贯,再次登录后才能够失效。因为要再读取一次./bash_profile。
为了不便,将设置写成了如下脚本:

echo export TMOUT=1000000 >> /root/.bash_profile
cat /root/.bash_profile
source .bash_profile
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
echo ClientAliveInterval=60 >> /etc/ssh/sshd_config
service sshd restart
cat /etc/ssh/sshd_config
service sshd restart
exit
总结:

ClientAliveInterval(/etc/ssh/sshd_config)、环境变量TMOUT(在/etc/profile或.bash_profile中设置)以及putty的"Seconds between keepalives“这些办法中,经
检测,只有TMOUT能够管制ssh连?在闲暇工夫超时,主动断开连接的工夫,数字单位为“秒”。
在设置了TMOUT后(非0),另外两个变量则不起作用的。

更多信息:
理解更多ssh_timeout_in_linux
如何减少ssh timeout工夫 increase linux ssh connection timeout quick guide
setup ssh keys to login linux without password