Configure SSH client to keep connection alive in Linux

To keep SSH connection alive you must edit your ~/.ssh/config file (if the file does not exist create it) and enter the following on top of the file:

Host *
ServerAliveInterval 60

First line applies this config to all hosts (*), and the second one is interval when to send keepalive packets in seconds (60).