Chinaunix首页 | 论坛 | 博客
  • 博客访问: 216824
  • 博文数量: 37
  • 博客积分: 2649
  • 博客等级: 少校
  • 技术积分: 490
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-02 10:31
文章分类

全部博文(37)

文章存档

2012年(3)

2009年(7)

2008年(27)

我的朋友

分类: LINUX

2008-11-26 10:57:55

高版本的Linux自带的OpenSSH在使用的时候,几分钟不操作的话就会自动断开连接,这是出于安全的考虑,但是对于需要长时间使用的用户来说很麻烦,每次都要重新连接。解决方法如下:

将/etc/ssh/sshd_config中的“ClientAliveInterval”设置取消注释,并把0改为一个较小的数值即可。具体说明参看下面的解释:

OpenSSH ClientAliveInterval

Using an OpenSSH server's ClientAliveInterval, it is possible for the ssh server to send periodic "keep alive" messages to the ssh client, keeping the connection open indefinitely. This is useful when a firewall or other packet filtering device drops idle connections after a certain period of time. Note that this is different from the KeepAlive directive in ssh_config.

From the sshd_config manpage:

      ClientAliveInterval
              Sets a timeout interval in seconds after which if no data has
              been received from the client, sshd will send 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 to protocol version 2 only.

Example (send "keep alive" messages every 5 minutes) on Red Hat Linux:

1. Add ClientAliveInterval 300 to /etc/ssh/sshd_config

2. Reload the sshd server configuration with /sbin/service sshd reload

Note: you may want to configure the ClientAliveCountMax value in sshd_config to set the number of times that "keep alive" messages are sent. If ClientAliveCountMax number of "keep alive" messages are not acknowledged by the ssh client, the connection is terminated by the ssh server. The default value of 3 should be sufficient for most users.
阅读(2489) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~