The strategy more simple is to log in the remoteserver and from there run the rsync command, with sudo privileges.
I assume you are working under Linux on both machines.
Let's we call localuser the username on the localserver, and remoteuser the username on the remoteserver.
- On the localserver is mounted an external unit in the path
- On the remoteserver there is a directory called
localuser@localserver ~> ssh -X remoteuser@remoteserver
It should ask you the password for the remoteuser on the remoteserver and
after it will show the prompt on the remote server:
Here you can write the rsync command:
sudo rsync -av /data/DirToSync localuser@localserver:/media/MyUsb
It will ask before the password for
sudo on the remote machine (the one of remoteuser@remoteserver) and after the password of the destination(the one of localuser@localserver).
- You need to be in the sudoers list of the remote machine (it means you have to have the right to run
sudo). Try to do
sudo ls on the remote server and give your password when requested. If it will execute the
ls command you are in that list. (It should be a really rare and insecure case if you were in that list and with no need of password; in that case you have not to write the password for
- It will be not asked you the passwords for the
ssh/rsync connections if you have generated and installed the ssh-keys.
ssh you can even send the
sudo command to
rsync from there to the localhost, but it is a little more complex syntax, see here for example, and you can incur in some problem because of
sudo on some version of linux.