Avoid ssh connection timeout

One way to avoid ssh connection timeout, is to use your ssh config file:

$ vim ~/.ssh/config

Add the following lines:

Host myhost
  HostName myhost.tld
  ServerAliveInterval 60
  Port 22
  User myusername

Or, if you want to set the keep alive for all hosts:

Host *
  ServerAliveInterval 60

Tip: now you can connect like this:

$ ssh myhost