How to write to remote side with sudo in rsync?
Here is the case, the user can not write directly to the remote side’s directory, while the user can sudo on the remote side and write the directory with sudo.
How to write to remote side with sudo in rsync?
On the source machine, run the rsync command with
--rsync-path="sudo rsync"
added. For example,
rsync -avxP --rsync-path="sudo rsync" /local/path/ user@remote:/remote/path/
Here, --rsync-path specifies the command to run on the remote machine.
Note that this work only if the user on the remote machine can do sudo without password. To set up password-less sudo, on the remote side,
sudo visudo
and add a line like this
USER ALL=NOPASSWD:PATH_TO_RSYNC
where, USER is the user name and PATH_TO_RSYNC should be the path of the rsync on the remote machine (you can find it out by which rsync).