Using ssh key with rsync

When your trying to use rsync and you need to send a SSH key, the how do you do it? Really simple:

rsync -Pav -e "ssh -i /dir/to/ssh/key" username@hostname:/start/dir/ /end/dir/

Of course you will need to setup the rsync command to your needs and directories for everything. The part that tells rsync to use a ssh key is this:

-e "ssh -i /dir/to/ssh/key"

If done properly, it should now connect now.

Leave a Reply