SECURECRT Session timeout exit processing when idle

Source: Internet
Author: User
Tags ssh server

Reference article: http://www.cnblogs.com/xuxm2007/archive/2011/04/21/2023611.html

http://yunwei.blog.51cto.com/381136/432672

Http://www.cnblogs.com/aoyihuashao/p/3298950.html

Company network reinforcement, resulting in the CRT connection is always disconnected, online query to the following two ways to set the SSH connection time.

The first way to successfully solve the problem, the second way is the most recommended online, but I do not know where to change the wrong is not applicable, but also write down for later reference use.

The first way to solve this problem:

Often when using SECURECRT, there will be timed out waiting for input:auto-logout, and then the session exits

Solution, there are two:

1. Modifications

Vim/etc/profile

Tmout=60 #or The number of seconds you want

. /etc/profile

Echo $TMOUT

2. Add in the. bash_profile file

Export tmout=60

The second way to solve this problem:

Method One,

1. Configure the server

#vi/etc/ssh/sshd_config

1) Find the Clientaliveinterval parameter, if you do not add a line of value is the second, such as you set to 120, it is 2 minutes

Clientaliveinterval 120

2) Clientalivecountmax

Refers to the time-out, which sets the number of times a timeout is allowed if the client is found to be not corresponding. such as 3, 5 and other customizations.

After modifying the two parameters, the following:

Clientaliveinterval 120

Clientalivecountmax 0 # # #在不允许超时次数

Reload the sshd service. Execute service sshd Reload

Method Two,

Locate the user's. SSH directory, such as the root user, which is located in:

/root/.ssh/

Create config file in this directory

Vi/root/.ssh/config

Add the following sentence:

Serveraliveinterval 60

Save exit, re-open the root user's shell, then SSH to the remote server,

Do not disconnect because of prolonged operation. Should be added after this, the SSH client will automatically communicate with the SSH server once every time, so the long operation will not be broken.

Method Three,

Modifying the/etc/profile configuration file

# Vi/etc/profile

Added: tmout=1800

This will automatically logout for 30 minutes without action.

Method Four,

Using expect simulation keyboard action, in idle time simulated to give a keyboard response, the following code is saved as XXX, and then executed with expect

#!/usr/bin/expect

Set Timeout 60

Spawn ssh U[email protected]

Interact {

Timeout {send "\x20"}

}

Expect XXX

Then follow the prompts to enter the password, so that every 300 seconds will automatically hit a space (\x20), the specific time interval can be set according to the situation.

Method Five,

If you are connected through a tool under Windows, you can set it to

SECURECRT: Option---terminal---anti-idle setting sends a string every few seconds, or the No-op protocol package

Putty:putty, Connection, Seconds between keepalives (0 to turn off), default is 0, change to 300.

SECURECRT Session timeout exit processing when idle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.