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:

--rsync-path="sudo rsync"

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 remoteuser@remotehost.com /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!)


  • Migrate Centos 7 from Single HDD to mdadm RAID 10 array:
  • How to change reserved blocks in Linux partition
  • Reading package lists... Done W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D46F45428842CE5E
  • Centos 7 A start job is running for dev-mapper-clx2droot.device (8min 44s / no limit)
  • USB 3.0 External HDD Enclosure Seagate UAS problems - [sdd] tag#1 CDB: Write(16) 8a 00 00 00 00 01 70 04 08 68 00 00 00 08 00 00
  • Centos 7 Cudaminer Nvidia setup guide
  • USB 3.0 PCI x1 Card Review VIA VL805 on Linux Review and Experience
  • rsync run as root sudo without password
  • Why won't my Linux Mint boot after I manually installed a new kernel?
  • cudaminer freezes Linux Mint taints kernel
  • Linux Mint Intel Screen Tearing Horizontal Line Solution Fix
  • process_usershare_file: stat of /var/lib/samba/usershares/dump failed. Permission denied - samba error solution
  • imagemagick pdf convert error solution - **** Warning: can't process font stream, loading font by the name. Can't find CMap Identity-UTF16-H building a CIDDecoding resource. Warning: falling back to Identity ordering **** Error reading a conte
  • php read file into variable
  • USB Device/MP3 Player not working properly and can't browse the device filesystem? Check the cable twice and again!
  • Centos/Linux Bash Script Warning when exiting/logging out of bash/shell/terminal for scripts running in the background
  • Wifi Antenna Extension Cable is called RP-SMA
  • Nvidia Linux Mint/Ubuntu screentearing horizontal line solution
  • Openshot 2.2 is very unstable always crashing in Linux Mint 18.1!
  • Apache SSL very slow response with Firefox Freezes/Loads Very slow when checking self-signed SSL certificate