When macOS ssh connects to the server, it always disconnects by itself, how to keep it alive
When macOS uses ssh to connect to the server, it always disconnects after a while, because the client does not send keep-alive packets to the server regularly.
solve
1. Switch to root
sudo su
2. Find the ssh configuration directory
cd /etc/ssh/
ls -al
can see what's inside
ssh_
The beginning is the configuration of the merchant, which is the configuration you use when connecting to others.
sshd_
It is the configuration as a server, which is the configuration that others use when connecting to you.
3. Modifyssh_config
edit ssh_config
added later
ServerAliveInterval 30
Just save the configuration file.
The unit of the following number is 秒
, which means how many seconds to send a keep-alive data to the server. The above configuration is 30 seconds
result
In this way, after connecting to the server again, it will not be automatically disconnected after a long time.