SSH connection timeout and freezing

Surely you have suffered this problem if you run a command through ssh and it take long to finish.

The ssh client is only waiting the command to finish, so ssh server close the connection because it doesn’t hear nothing from the client for a while.

To avoid this, you can setup in your client, to send a token each X seconds:

vim ~/.ssh/config

And add in the file:

Host *
ServerAliveInterval 180

You can change * for specific host and the configuration will only affect that site.