使用xshell-ssh连接服务器被经常意外中断(Disconnected from remote host)

来源:互联网 发布:保温杯十大排名 知乎 编辑:程序博客网 时间:2024/05/22 06:59

最近使用Xshell使用服务器,经常连接上使用一会就会被自动中断,很是闹心,并且出现以下的错误提示:

Socket error Event: 32 Error: 10053.Connection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(测试) at 09:35:58.Type `help' to learn how to use Xshell prompt.

重新登录使用last指令查看登录情况,发现好几个终端依然登着,但是ip地址变化了,好吧,很有可能是网络ip地址变化导致xshell自动断开连接。于是修改本机ip为固定地址发现就不会轻易断了。

root     pts/3        183.186.203.80   Sat Aug 26 09:41   still logged in   root     pts/2        171.127.72.216   Sat Aug 26 09:33   still logged in   root     pts/2        118.77.199.116   Sat Aug 26 09:30 - 09:32  (00:01)    root     pts/1        171.127.203.17   Sat Aug 26 09:05   still logged in   root     pts/1        118.77.199.229   Fri Aug 25 09:16 - 09:30  (00:14)    

另外还有种情况是本机网络dns变化也会导致xshell自动断开连接,这种情况通过修改ssh配置文件将其中“UseDNS yes”去掉注释并改成no即可,过程如下。

vim /etc/ssh/sshd_config
...#ClientAliveInterval 0#ClientAliveCountMax 3#ShowPatchLevel noUseDNS no#PidFile /var/run/sshd.pid#MaxStartups 10:30:100#PermitTunnel no#ChrootDirectory none...

修改完配置记得重新启动ssh(centos7)

systemctl restart sshd
阅读全文
0 0
原创粉丝点击