It usually happens that the ssh connection suddenly hangs after left for awhile. This is because the ssh server is configured to disconnect the connection if nothing is sent from the client.
To make the connection stay alive forever. Use the following methods.
- In the ssh command, add
-o ServerAliveInterval=100flag. With this flag, for each 100 second, the ssh client automatically sends a dump packet to keep the connection alive.
ssh -o ServerAliveInterval=100 firstname.lastname@example.org
Host my-host HostName example.com User user-name ServerAliveInterval 100