解决 SSH Connection closed by foreign host 问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tojohnonly/article/details/79746588

用 Xshell 连接服务器总是报错 :

Connection closed by foreign host.
Disconnected from remote host...

原因可能是 SSH 服务器没设置保活时间间隔 , 具体设置如下 :

# vim /etc/ssh/sshd_config

添加两行 , 或去掉注释 :

ClientAliveInterval 60
ClientAliveCountMax 3

重启 SSH 服务 :

# /etc/init.d/ssh restart
# systemctl restart sshd

ClientAliveInterval 参数数值是秒 , 是指超时时间 , 上面设置的是一分钟 ;
ClientAliveCountMax 设置允许超时的次数 , 上面设置的是允许三次 , 之后就关闭连接 ;

作者 Github : tojohnonly , 博客 : EnskDeCode

猜你喜欢

转载自blog.csdn.net/tojohnonly/article/details/79746588
今日推荐