Solaris10 如何设置空闲ssh连接超时断开

在ssh的配置文件中有2个参数可以控制空闲连接超时断开。这2个参数是ClientAliveCountMax和ClientAliveInterval。

Solaris10上设置空闲ssh连接超时断开的方法如下:

修改/etc/ssh/sshd_config文件,在文件中加入以下内容:
ClientAliveCountMax = 0
ClientAliveInterval = 600   #单位是秒

然后重启ssh服务:
#> svcadm restart ssh

这两个参数的说明参见man sshd_config

ClientAliveCountMax

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

         The default value is 3. If  ClientAliveInterval  (below)
         is  set  to  15,  and ClientAliveCountMax is left at the
         default, unresponsive ssh clients will  be  disconnected
         after approximately 45 seconds.

     ClientAliveInterval

         Sets a timeout interval in seconds after  which,  if  no
         data  has  been  received  from the client, sshd sends a
         message through  the  encrypted  channel  to  request  a
         response  from  the client. The default is 0, indicating
         that these messages will not be sent to the client. This
         option applies only to protocol version 2.

需要说明的是man里的说明似乎有错误。按照man里面的说明,如果设置ClientAliveCountMax=3,ClientAliveInterval=15,空闲连接应该在45秒左右自动断开,但实际测试时发现必须设置ClientAliveCountMax=0,空闲连接才能自动断开。

Solaris10 如何设置空闲ssh连接超时断开

时间: 2024-10-28 17:02:50

Solaris10 如何设置空闲ssh连接超时断开的相关文章

Putty解决SSH连接超时断开的问题

1 在 linux下的ssh命令:vim /etc/ssh/ssh_config 然后找到里面的ServerAliveInterval 参数,如果没有你同样自己加一个就好了.参数意义相同,都是秒数,比如9分钟: ServerAliveInterval 540 putty中解决SSH连接超时断开的两种方法 2 Putty 启用putty keepalive putty -> Connection -> Seconds between keepalives ( 0 to turn off ),默认

SSH连接自动断开的解决方法(deb/rpm)

######### 修改后的: ## # tail -f -n 20 sshd_config#MaxStartups 10:30:60#Banner /etc/issue.net # Allow client to pass locale environment variablesAcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server # Set this to 'yes' to enable PAM authenticat

SSH连接超时不自动断开

Putty 启用putty keepalive putty -> Connection -> Seconds between keepalives ( 0 to turn off ),默认为0,改为60. 更改ssh服务器的配置文件/etc/ssh/sshd_config ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔, 默认是0,不发送.而ClientAliveInterval 60表示每分钟发送一次,然后客户端响应,这样就保持长连接了.这里比较怪的地方是:不

【转】MySQL连接超时断开的问题

这遍文章转过来做个笔记,时不时看看. 转:http://blog.csdn.net/nethibernate/article/details/6658855 Exception如下: [html] view plaincopy org.hibernate.util.JDBCExceptionReporter - SQL Error:0, SQLState: 08S01 org.hibernate.util.JDBCExceptionReporter - The last packet succe

设置Mysql的连接超时参数

在Mysql的默认设置中,如果一个数据库连接超过8小时没有使用(闲置8小时,即 28800s),mysql server将主动断开这条连接,后续在该连接上进行的查询操作都将失败,将 出现:error 2006 (MySQL server has gone away)!. 查看mysql server超时时间: msyql> show global variables like '%timeout%'; 设置mysql server超时时间(以秒为单位): msyql> set global w

ssh连接超时中断问题解决方案

当在终端使用ssh命令连接到服务器时,如果一段时间没有活动连接会被中断,以下有两种方案可以解决: 一.修改ssh客户端配置 编辑客户端 /etc/ssh/ssh_config (或~/.ssh/config 对当前用户生效) 文件,修改以下两个配置项(没有就自己添加) ServerAliveInterval 60  #ssh客户端每60秒会发送一个keepalive请求给服务端,服务端响应,从而保持连接: ServerAliveCountMax 3 #客户端发出请求后,服务器端没有响应达到3次,

CentOS 静态IP设置和SSH连接

VirtualBox设置网络 在安装完成了CentOS之后,我在virtualbox中配置两个网络如下: 一个网络为NAT,另一个则为HOST-ONLY 其中NAT网络进一步配置其端口转发路由如下: 点击Advanced -> Port Forwarding 上面的host port就是真实机的端口,guest port就是虚拟机的.配置完成之后,guest machine中会出现两个虚拟网上ifcfg-enp0s3.ifcfg-enp0s8 依次对应两个网络 配置ifcfg-enp0s3的dh

Linux的SSH登录超时自动断开连接设置

关于ssh登录超时断开连接的设置有两个方面可以设置 1.修改sshd服务的配置文件sshd_config的内容 #ClientAliveInterval 0   指定了服务器向客户端请求消息的时间间隔 #ClientAliveCountMax 3   连接用户最大值 2.ssh -o ConnectTimeout=Time IP ssh -o ConnectTimeout=3 192.168.0.10 3.修改环境变量配置文件(.bash_profile /etc/bash_profile /e

Nginx服务优化(五)设置连接超时

配置Nginx实现连接超时 在企业网站中,为了避免同一个客户长时间占用连接,造成资源浪费,可设置相应的连接超时参数,实现控制连接访问时间. 1.用"curl -I"命令查看connection参数 [[email protected] nginx]# curl -I 192.168.52.131 HTTP/1.1 200 OK Server: nginx/1.1.1 Date: Wed, 13 Nov 2019 11:06:54 GMT Content-Type: text/html