web analytics

Blog

How to do data transfer using Rsync without root access

Tags: data transferrsyncsudo

Published on: September 20, 2014 by Arnold Pablo

How to do data transfer using Rsync without root access

Scenario:

There could be many situations where you do not have a root password for many of the servers you interact with where you can not SSH directly in as the root user. Also, the ssh daemons are wisely configured with ‘PermitRootLogin’ set to ‘no’ so a password would be moot anyway. Let us see how to use the rsync without root access in such situations.

Most probably you may have sudo permissions on the servers so that you can connect under your username and sudo the privileged commands as needed.

Set NOPASSWD in the /etc/sudoers file. Here we could have used the username instead of the wheel group

%wheel ALL= NOPASSWD:/usr/bin/rsync

Then use the –rsync-path option to specify the sudo wrapper.

rsync -a -e "ssh" --rsync-path="sudo rsync" admin@xx.xx.xx.xx:/home/user/ /home/user
In normal cases the above should work, If you are getting a warning message like below, there you will need to go for Option 2 as mentioned in the Reference #1, which may or may not work for you
[root@b ~]# rsync -a -e “ssh” –rsync-path=”sudo rsync” ssh_user@xx.xx.xx.xx/home/user/ /home/user
Address xx.xx.xx.xx maps to tr.xxx.xx, but this does not map back to the address – POSSIBLE BREAK-IN ATTEMPT!
ssh_user@xx.xx.xx.xx’s password:
sudo: no tty present and no askpass program specified
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [receiver=3.0.6]

You may also get the same message, if the rsync command is not installed in the source server from which you are rsyncing and in such case, you would need to install rsync package.

References

  1. http://crashingdaily.wordpress.com/2007/06/29/rsync-and-sudo-over-ssh/
  2. http://lists.samba.org/archive/rsync/2004-August/010439.html

Category : Howtos, Linux, Troubleshooting

Arnold Pablo

Arnold Pablo

Technology always fascinated me and continues to do so. I started my career back in 2004 as a Junior System Admin and worked in various capacities both in technical and managerial roles. I love to experiment and try out new OSS projects and in free time, go for cycling to the interiors of God's own country, Kerala!

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Get new updates

Categories

$0.000 items