Chinaunix首页 | 论坛 | 博客
  • 博客访问: 156096
  • 博文数量: 25
  • 博客积分: 2011
  • 博客等级: 大尉
  • 技术积分: 280
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-22 23:16
文章存档

2009年(22)

2008年(3)

我的朋友

分类: LINUX

2009-06-22 16:04:10

[转载]SSH超时断开连接的解决办法
2007-10-15 22:26

高版本的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.
阅读(1696) | 评论(0) | 转发(0) |
0

上一篇:Apache与Jira的集成

下一篇:用C/C++写CGI程序

给主人留下些什么吧!~~