红联Linux门户
Linux帮助

telnet和ssh登录超时自动断问题

发布时间:2009-05-21 01:19:23来源:红联作者:jjwspj
服务器是RHEL5.1 ,同过secureCRT telnet或ssh2 到服务器,发现只要有1分多钟不使用,客户端自动断了,很奇怪,查了服务器上的env,也没有发现和时间有关的变量,还请各位高人看看这是怎么回事?
文章评论

共有 5 条评论

  1. jjwspj 于 2009-05-22 15:59:30发表:

    试过,可以解决,非常感谢linuxcn ,但还是有疑问,难道RHEL5.1默认就在某个配置文件做过TMOUT设置,就是不清除具体在哪设置的。

  2. linuxcn 于 2009-05-22 11:19:55发表:

    [i=s] 本帖最后由 linuxcn 于 2009-5-22 11:21 编辑 [/i]

    你是否试过这一部分:

    you must be root to do this part

    create a file called /etc/profile.d/autologout.sh, enter::

    # vi /etc/profile.d/autologout.sh


    Append the following code:

    # auto out in 50 minutes
    TMOUT=3000

    readonly TMOUT
    export TMOUT

    Save and close the file. Set permissions:
    # chmod +x /etc/profile.d/autologout.sh
    Above script will implement a 50 minute idle time-out for the default /bin/bash
    shell. You can also create tcsh version as follows:
    # vi /etc/profile.d/autologout.csh
    Append the following code:

    set -r autologout 5

    Save and close the file. Set permissions, enter:
    # chmod +x /etc/profile.d/autologout.csh

  3. jjwspj 于 2009-05-21 15:40:15发表:

    感谢linuxcn兄的回复,修改/etc/ssh/sshd_config配置无法解决,我的问题是telnet和ssh2都有这个问题,所以系统应该还有一个配置需要修改,但不知道在哪? 关于TMOUT,我其实已在.bashrc加过,但不起作用。

  4. linuxcn 于 2009-05-21 13:52:55发表:

    This offers your a better solution:

    You can configure any Linux system to automatically log users out after a
    period of inactivity. Simply login as the root user and
    create a file called /etc/profile.d/autologout.sh, enter::

    # vi /etc/profile.d/autologout.sh


    Append the following code:

    TMOUT=300
    readonly TMOUT
    export TMOUT

    Save and close the file. Set permissions:
    # chmod +x /etc/profile.d/autologout.sh
    Above script will implement a 5 minute idle time-out for the default /bin/bash
    shell. You can also create tcsh version as follows:
    # vi /etc/profile.d/autologout.csh
    Append the following code:

    set -r autologout 5

    Save and close the file. Set permissions, enter:
    # chmod +x /etc/profile.d/autologout.csh
    Dealing with ssh clients

    SSH allows administrators to set an idle timeout interval. After this interval
    has passed, the idle user will be automatically logged out. Open /etc/ssh/sshd
    config file, enter:
    # vi /etc/ssh/sshd config
    Find ClientAliveInterval and set to 300 (5 minutes) as follows:

    ClientAliveInterval 300
    ClientAliveCountMax 0

    Save and close the file. Restart sshd:
    # service sshd restart

  5. linuxcn 于 2009-05-21 13:38:54发表:

    try this

    editing the /etc/ssh/sshd_config

    Uncomment the line

    ClientAliveInterval 300

    and restarted sshd

    Good luck