When macOS ssh connects to the server, it always disconnects by itself, how to keep it alive

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.

insert image description here

3. Modifyssh_config

edit ssh_configadded 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.

Guess you like

Origin blog.csdn.net/KimBing/article/details/131269549