方法 修改sshd配置文件 步骤 去掉TCPKeepAlive yes的注释去掉注释#ClientAliveInterval 0 #ClientAliveCountMax 3 修改ClientAliveInterval 30 ClientAliveCountMax 86400 第一行为客户端每隔多少秒向服务发送一个心跳数据第二行为客户端多少秒没反应,服务器自动断掉连接 重启服务systemctl restart sshd