If at connecting to hosting via SSH across macOS terminal the connection is terminated after some time of inactivity, do the following:
Open the SSH configuration file for editing by running the command:
sudo nano /etc/ssh/ssh_config
When prompted for a password, enter the device administrator password (no characters will be displayed on the screen when you enter the password) and press Enter.
At the bottom of the config file after
add the following lines:
Save changes with the combination ⌘+O.
Close the editor with a shortcut ⌘+X.
Check for the problem.
ServerAliveInterval is responsible for how often (in seconds) your PC will send a zero packet to keep the connection active. If the problem persists, try lowering the value, for example, to
5... If this does not work, then it is possible that the problem is in the router used.