I need to make periodic backups of a directory on a remote server which is a virtual machine hosted by a research organisation. They mandate that access to VMs is through ssh keys, which is all good, except that I can't figure out how to point rsync to the ssh key for this server.
Rsync has no problem if the key file is ~/.ssh/id_rsa
, but when it is something else I get Permission denied (publickey)
.
With ssh I can specify the identity file with -i
, but rsync appears to have no such option.
I have also tried temporarily moving the key on the local machine to ~/.ssh/id_rsa
, but that similarly does not work.
tl;dr
Can you specify an identity file with rsync?
sudo rsync
, which doesn't use one's own ssh keys, for some reason. – ijoseph Jul 27 '18 at 21:19rsync -aAP "sudo -u user ssh" user@server:dir local_dir
when syncing from cron scripts which run as root – Martin Pecka Dec 11 '18 at 14:16