How to keep rsync over SSH connection permanent - no broken pipe

Solution 1:

This works providing your running OpenSSH.

Edit your ~/.ssh/config file and add the following to activate the keep-alive system for just your user for all host connected to.

If you want to do this just for one host, switch the * with a host name of your choosing.

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

Solution 2:

You should use the parameter 'ServerAliveInterval' as below:

rsync -avzhe 'ssh -o ServerAliveInterval=60' local/dir/files your_user@remote:/destination/