Hi,
I am trying to use rsync utility through ssh to synchronize some root files of 2 servers.
I have a rsyncusr user in each server. I configured ssh with no password. I set NOPASSWD in the /etc/sudoers file:
rsyncusr ALL= NOPASSWD:/usr/bin/rsync
In order to make rsync able to sudo and be able to sync root files from one server to other server.
So far, I was not be able to transfer the files preserving the permissions (owner, group, etc).
To illustrate with an example. I have a file in the remote host dev3test:
-rw-r----- 1 root system 12615680 Jan 19 16:27 dev3test
I have 2 servers:
Local: roidev
remote: roidev3
First scenario:
If I try from the local host to pull the file from the remote host to the local host:
rsyncusr@roidev-/dbbackup $ rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" rsyncusr@10.144.206.84:/deletefs/dev3test
The file is transferred to the local host with the following permissions :
rw-r----- 1 rsyncusr db2iadm1 12615680 Jan 19 16:27 dev3test
The owner and the group is changed.
Second scenario:
If I try from the remote host to push the file from the remote host to the local host:
rsyncusr@roidev3-/home/rsyncusr $ rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" /deletefs/dev3test rsyncusr@10.144.206.20:/dbbackup
I got the following error
rsync: send_files failed to open "/deletefs/dev3test": Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
Third scenario:
Loggin as a root user in the local host or in the remote host, executing the same commands:
root@roidev-/dbbackup# rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" rsyncusr@10.144.206.84:/deletefs/dev3test /dbbackup
rsyncusr's password:
root@roidev3 / # rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" /deletefs/dev3test rsyncusr@10.144.206.20:/dbbackup
rsyncusr@10.144.206.20's password:
I can get the transfer file with the right permissions, but I am requiring for rsyncusr password.
-rw-r----- 1 root system 12615680 Jan 19 16:27 dev3test
I can not loggin as root through the network, only I can do sudo.
I would like to know if there is a way to transfer root files preserving permissions as a different user and without password, using rsync with ssh.
thanks in advance
Samalogo