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