linux set SSH Server to keep long connection

How to make the server automatically disconnect from the terminal that has not been operated for a certain period of time? # vi /etc/profile increase: TMOUT=1800 This will automatically LOGOUT if there is no operation for 30 minutes

 

OpenSSH is based on security reasons. If the user is idle for a period of time after connecting to the SSH Server , the SSH Server will automatically terminate the SSH connection after a certain period of time.  I am used to long-term connections, so I need to make the following modifications:

1. Open the ssh configuration file: # vim /etc/ssh/sshd_config
Add the following two parameters to save:

TCPKeepAlive yes
ClientAliveCountMax 360

Note: The former parameter indicates that the TCP connection is to be maintained, and the latter parameter indicates the value of automatically terminating the connection after the client's SSH connection is idle, in minutes.

2. Restart sshd to take effect:

/etc/init.d/sshd restart

Note: This method applies to OpenSSH on all Linux distributions

 

ubuntu settings

How do I keep the ssh connection server or sshtunnel connected?

  In fact, it is also very convenient, just add two parameters to the /etc/ssh/ssh_config file.

  1TCPKeepAliveyes

  2ServerAliveInterval300

  The former parameter means to keep the connection, the latter parameter means to send a data packet to the server every 5 minutes to indicate "I'm still alive"

  If you do not have root privileges, it is also possible to modify or create ~/.ssh/ssh_config

 

Reprinted from: http://blog.chinaunix.net/uid-8473611-id-3069386.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488419&siteId=291194637