If at connecting to hosting via SSH across macOS terminal the connection drops after a while of inactivity, do the following:
sudo nano /etc/ssh/ssh_config
Host *
add the following lines:ServerAliveInterval 120 TCPKeepAlive no
Parameter 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.