当前位置: 代码迷 >> 综合 >> centos 设置 ssh超时自动断开链接
  详细解决方案

centos 设置 ssh超时自动断开链接

热度:44   发布时间:2024-01-25 09:47:27.0

1.针对特定用户设置

cd ~ #用户家目录vi .bash_profileexport TMOUT=600 #加入超时时间单位ssource .bash_profile #重新加载文件

2.全局设置

vi /etc/ssh/sshd_configClientAliveInterval 60 #超时时间ClientAliveCountMax 3 #允许最大次数service sshd restart #重启服务

ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔, 默认是0,不发送.而#ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.ClientAliveCountMax, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开

  相关解决方案