1. Modify server-side Etc/ssh/sshd_config
Copy Code code as follows:
Clientaliveinterval #server每隔60秒发送一次请求给client, then the client responds, thus keeping the connection
Clientalivecountmax 3 #server发出请求后, the client does not respond to the number of times reached 3, automatically disconnected, normally, client will not be unresponsive
2. Modify the etc/ssh/ssh_config of the client side to add the following: (without permission to change server configuration)
Copy Code code as follows:
Serveraliveinterval #client每隔60秒发送一次请求给server, and then the server responds, thus keeping the connection
Serveralivecountmax 3 #client发出请求后, the server side does not respond to the number of times reached 3, automatically disconnected, under normal circumstances, the server will not be unresponsive
Another way:
Do not modify the configuration file
In the command arguments Ssh-o serveraliveinterval=60 This will only maintain a persistent connection in the desired connection, after all, not all connections should remain persistent
For example:
In accordance with the first option, you need to restart the SSH service after the modification, OK:
Copy Code code as follows:
PISOWEBSV02:/ETC/SSH # service Sshd
Usage:/etc/init.d/sshd {start|stop|status|try-restart|restart|force-reload|reload|probe}
PISOWEBSV02:/ETC/SSH # service Sshd restart
Shutting down SSH Daemon done
Starting SSH Daemon