点击小眼睛开启蜘蛛网特效

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

最近使用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 no
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
...

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

 systemctl restart sshd

 

  点赞
本篇文章采用 署名-非商业性使用-禁止演绎 4.0 国际 进行许可
转载请务必注明来源: https://oldpan.me/archives/disconnected_from_remote_host

   关注Oldpan博客微信公众号,你最需要的及时推送给你。


发表评论

邮箱地址不会被公开。 必填项已用*标注

评论审核已启用。您的评论可能需要一段时间后才能被显示。