求助!最近用 xshell6 连接腾讯云老是被断开?

  • 回答 (2)
  • 关注 (0)
  • 查看 (439)

这两天使用 xshell 6 连接腾讯云老是被断开,哪位大佬知道是为啥吗?

系统:centos 7.6 64位

断开日志:

Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(xxx.xxx.xxx.xxx) at 10:49:11.
用户6148560用户6148560提问于
HappyLau谈云计算专注于公有云,私有云解决方案,在kubernetes,openstack,kvm,ceph,linux,shell有丰富的实战经验。回答于
推荐已采纳

xshell官网有提到类似的问题,可以尝试禁用windows的防火墙试试,xshell官网参考https://www.syxin.com/2018/06/xshell-error-socket-error-event-32-error-10053/

_逗你玩_

腾讯 · 客户端安全 (已认证)

回答于

保持连接

配置服务端

SSH总是被强行中断,导致效率低下,可以在服务端配置,让 server 每隔30秒向 client 发送一个 keep-alive 包来保持连接:

vim /etc/ssh/sshd_config

添加

ClientAliveInterval 30
ClientAliveCountMax 60

第二行配置表示如果发送 keep-alive 包数量达到 60 次,客户端依然没有反应,则服务端 sshd 断开连接。如果什么都不操作,该配置可以让连接保持 30s*60 , 30 min

重启本地 ssh

sudo service ssh restart

如果找不到 ssh,”Failed to restart ssh.service: Unit ssh.service not found.” ,需要安装

sudo apt-get install openssh-server

配置客户端

如果服务端没有权限配置,或者无法配置,可以配置客户端 ssh,使客户端发起的所有会话都保持连接:

vim /etc/ssh/ssh_config

添加

ServerAliveInterval 30
ServerAliveCountMax 60

本地 ssh 每隔30s向 server 端 sshd 发送 keep-alive 包,如果发送 60 次,server 无回应断开连接。

下面是 man ssh_config 的内容

ServerAliveCountMax Sets the number of server alive messages (see below) which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session. It is important to note that the use of server alive messages is very different from TCPKeepAlive (below). The server alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The server alive mechanism is valuable when the client or server depend on knowing when a connection has become inactive.

The default value is 3. If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds. This option applies to protocol version 2 only; in protocol version 1 there is no mechanism to request a response from the server to the server alive messages, so disconnection is the responsibility of the TCP stack.

ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server, or 300 if the BatchMode option is set. This option applies to protocol version 2 only. ProtocolKeepAlives and SetupTimeOut are Debian-specific compatibility aliases for this option.

可能回答问题的人

  • 腾讯云计算产品团队

    腾讯云 · 产品团队 (已认证)

    154 粉丝0 提问0 回答
  • CVM 产品团队

    34 粉丝0 提问9 回答
  • 小仙女和科学家

    10 粉丝0 提问0 回答
  • 怕冷的阳阳

    腾讯云 · 高级工程师 (已认证)

    39 粉丝1 提问1 回答
  • DRRR

    腾讯云 · 产品经理 (已认证)

    7 粉丝0 提问4 回答
  • candyxiao

    腾讯 · 高级产品经理 (已认证)

    16 粉丝0 提问7 回答

扫码关注云+社区

领取腾讯云代金券