江苏省吴江市双板桥路3号兴源网络

0512-63028342

ly@wjxy.net.cn

SSH 配置客户端保持连接

Windows

  1. 打开文件资源管理器,进入路径:C:\Users\你的用户名\.ssh(如果没有 .ssh 文件夹,可手动创建)
  2. 在该文件夹中新建或编辑 config 文件(无扩展名),添加以下内容:

   Host *

            ServerAliveInterval 30

           ServerAliveCountMax 3

  • ServerAliveInterval 30:每 30 秒向服务器发送一次保持连接的请求
  • ServerAliveCountMax 3:如果连续 3 次无响应则断开连接

——————————————————————————–

Linux

# 编辑或创建config文件
vim ~/.ssh/config

添加以下内容(作用于所有服务器):
Host *
    # 客户端每隔30秒向服务器发送一次心跳
    ServerAliveInterval 30
    # 允许3次无响应后断开
    ServerAliveCountMax 3

发表回复