How to Setup Rsync with SSH without Password on Ubuntu / Debian

Rsync is awesome tool for synchronize local files or directories with files and directories on remote server. Rsync is commonly used for data backup.

For rsync installation you can read this article. Below is command line how to use rsync with ssh.

$ rsync -avz -e ssh kumkum@ /data/backup

You will be asked for a ssh password before rsync can start synchronizing. To bypass this password prompt we have to setup ssh public key. Execute this command to generate ssh key:

$ ssh-keygen
 Generating public/private rsa key pair.
 Enter file in which to save the key (/root/.ssh/id_rsa):
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:

Just press Enter for three prompt lines above. Next step is to copy ssh public key to remote server:

$ ssh-copy-id -i ~/.ssh/

After that, test by doing ssh to remote server:

$ ssh

If remote server let you login without password, it means your ssh public key has been copied to remote server successfully.

Now we do rsync command again:

$ rsync -avz -e ssh kumkum@ /data/backup

and… blink! Your rsync process will start without password prompt.

Leave a Reply

Your email address will not be published. Required fields are marked *