SSH is disconnected for a long time without operation. It is intolerable. Every time I want to solve this problem, BUT I am too lazy to do it.

Solution 1: Configure the server

1. Connect to SSH

SSH [email protected]Copy the code

2. Edit sshd_config

vim /etc/ssh/sshd_config
Copy the code

3. Go to ClientAliveInterval and remove the #

ClientAliveInterval 60 = ClientAliveInterval 60Copy the code

4, Find ClientAliveCountMax, remove the # from the top,

If the client does not respond to a request sent by the server, it will count one timeout. You can set this value to a larger value. ClientAliveCountMax 666Copy the code

In this case, even if no operation will not be disconnected, according to their own needs to adjust the value.

Solution 2: Configure the client

The blogger is a MAC, if it is Windows work it out

1. Edit sshd_config

vim /etc/ssh/ssh_config
Copy the code

2, add the following 2, if there is modification, otherwise new, meaning the same as the server configuration, no further elaboration.

ServerAliveInterval 60
ServerAliveCountMax 666
Copy the code

Solution 3: Connect SSH specified parameters

Set the value of ServerAliveInterval to a larger value so that no timeouts occur.

SSH [email protected] - o ServerAliveInterval = 99999Copy the code

conclusion

I prefer solution two because as long as the client is configured it doesn’t matter which server it connects to. Servers have to be configured for each one. It depends on your preferences and the scene.