rsync run as root sudo without password -
rsync run as root sudo without password
This is a common issue, what if a issue shouldn't have root but you want to use that user to make a full backup of a system? They of course need root access.
You can actually just give them passwordless sudo access to rsync in /etc/sudoers:
sudo vi /etc/sudoers
yourusername ALL = NOPASSWD: /usr/bin/rsync
Here is how you would execute rsync:
The key thing for the remote host is to use:
This (above) executes rsync on the remote host as root.
To run rsync locally with root privileges you also need to start it with "sudo rsync" as shown below.
sudo rsync -e 'ssh -i /home/yourlocalusername/.ssh/id_rsa' --rsync-path="sudo rsync" -Phaz firstname.lastname@example.org /remote/path /local/path
It is also important to use the -e swtich as above if you are depending on a key to login (which most will be):
'ssh -i /home/yourlocalusername/.ssh/id_rsa'
You are basically specifying your keyfile location so that root doesn't use its own since you are likely not using root's ssh public key (and shouldn't be!)