Linux Server set time limit for remote connections

Source: Internet
Author: User
Tags set time

Modified in the/etc/ssh/ssh_config file: ConnectTimeout 300//is 5 minutes if the login prompt state: logingracetime 300
To restart the SSH service after the change: service SSH restart # Ubuntu service sshd Restart # Redhat

The answer on the Internet is like this, but I tried it as if ConnectTimeout only made the local bash break, and the remote connection was not disconnected. So, I tried another way:

#vim/etc/profile

Export tmout=300

If no input is available within 300 seconds, exit the current bash.

I tried, both remote and native bash exited (I used a VMware virtual machine). Be the winner for the moment!

But this is the case when the client does not send the request packet to keep the connection, if the server is forced to disconnect it? Get the answer like this:

Write a script and kill it in 2 hours.

Get the script to kill .....


#fuser-K/dev/pts/*

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/84/wKioL1VLI1eSvDv_AAER0of8tfI531.jpg "title=" 20150507162639.png "alt=" Wkiol1vli1esvdv_aaer0of8tfi531.jpg "/>

#pkill-kill-t pts/*

Both of them should be able to kill all the connections.


But I tried not to succeed, and I did not understand the meaning of the order, so I used my own trouble to kill a bit:

Kill-9 ' ps aux | grep ssh |grep @ |awk ' {print $} '

I can use it here.

Writing is not complete and in-depth, I hope to know that friends can give an inspiration, will be greatly appreciated.


In addition, the Xshell tool is connected by:


The server will be disconnected by default, but the connection tool will set the Send activity status;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6C/84/wKioL1VLI9ai00wjAACJYLG-g90556.jpg "title=" Baidushurufa_2015-5-7_16-29-3.jpg "alt=" Wkiol1vli9ai00wjaacjylg-g90556.jpg "/>

In the properties-connect-keep-alive state, keep the session active in front of the box, remove this tick, and OK!


Linux Server set time limit for remote connections

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.