~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Rsync with a Different Key

Published on

Updated on

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

To use Rsync with a different key, follow the command structure below.

rsync -e "ssh -i $HOME/.ssh/key" user@hostname:/from/dir/ /to/dir/

Though for syncing my local website to my VPS, I usually like having more options with my rsync command

rsync -Paz --delete -e "ssh -i $HOME/.ssh/key" user@hostname:/from/dir/ /to/dir/

Quick option definitions (from man page)

Option Description
-e Allows you to override the default shell used as the transport for rsync. Command line options are permitted after the command name.
-a, –archive This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when –files-from is specified, in which case -r is not implied. Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.
-P Equivalent to –partial –progress. Its purpose is to make it much easier to specify these two options for a long transfer that may be interrupted.
-z, –compress Compress file data during the transfer
–delete Delete extraneous files from dest dirs
Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :