Rsync without password to remote server with non-default SSH port

This is the normal rsync command, assuming your are using port 2222 for the SSH port :

rsync -avz -e “ssh -p 2222” /local_folder user@xx.xx.xx.xx:/remote_folder

However, this will require you to fill in the password. If the remote server is trusted, just create the key pair.


Enter file in which to save the key (/user/.ssh/id_rsa): put_any_name_here
Enter passphrase (empty for no passphrase):  (just press enter)
Enter same passphrase again: (just press enter)
Your identification has been saved in put_any_name_here
Your public key has been saved in

Copy the key to remote server :

ssh-copy-id -p 2424 -i /user/.ssh/ xx.xx.xx.xx

The key is now copied and you may log in to the remote server without using password anymore

ssh -p 2222

Schedule the rsync in a cronjob, that’s all 🙂