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!)


  • Install Windows From a Linux TFTP Server instead of using WDS Solution
  • How To Secure Samba NMBD/SMBD to bind to a specific IP address
  • tftp: client does not accept options - solution if you are using UEFI PXEBoot disable it!
  • Linux how to view video card make and exact model
  • Authentication refused: bad ownership or modes for directory /home/user SSH Public Key Authentication Failed Solution
  • How to Update Linux /usr/share/misc/pci.ids
  • pcimodules and lspci not working alternative solution
  • How to disable Google Fonts in Wordpress
  • Unable to load dynamic library /usr/lib64/php/modules/php_openssl
  • mysqld in Linux hacked
  • W: GPG error: http://archive.debian.org squeeze Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA NO_PUBKEY 64481591B98321F9
  • cannot mount kvm ntfs image
  • h264 DVR security camera footage cannot be played
  • dhcpd.conf how to secure so only known and allowed clients will be given dhcpd IP address leases
  • Thunderbird E-mail List Blank White but e-mails still clickable and viewable
  • css responsive images
  • responsive table without changing much code solution
  • yum how to install old obsolete packages
  • PHP Howto Store Value of Included File Output Into Variable
  • PHP Migration from 5.3 to 5.4+ and dealing with deprecated functions