Skip to main content
duffn.dev

rsync While Specifying an SSH key

Share: 

If you need to rsync to a server and specify a different SSH than your default you certainly can, though it's not initially intuitive. If you read the man page, however, and see the -e flag, then it starts to make sense. This flag says that it's used to "specify the remote shell to use". With that, we can create an rsync command to use a different SSH key.

rsync -azP -e "ssh -i ~/.ssh/my_other_key" --delete local_dir/ [email protected]:/remote_dir/