LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to use rsync as root (https://www.linuxquestions.org/questions/linux-general-1/how-to-use-rsync-as-root-429458/)

hueofwind 03-28-2006 08:06 PM

how to use rsync as root
 
Hi, everyone:

I met a problem when i tried to use rsync to back up files between two machines. The problem is only when u rsync as root on the target machine can u keep all the file attributes like owner, group. If u use a non-root user, the files' owner and group will be changed to the same as the user being used.

But both two machines, for the security reason, root are disabled for login. In their sshd_config file, PermitRootLogin is set to no.

How can I solve this problem without changing PermitRootLogin? Can sudo be used in this case?

Thanks a lot!

Henry

kilgoretrout 03-29-2006 10:06 AM

If you're not using a script the answer is easy. Login as an ordinary user, su to root, and run rsync. If you are automating the process with a cron script, you want to set up an ssh key for authentication so you don't need to be there to enter a password.

hueofwind 03-29-2006 04:47 PM

thank, kilgoretrout!

But the problem is none of the two machines supports root login, which means if I ssh login to target machine then use rsync, I may not have access right to some directories on source machine.

What's ur opinion?

Henry

gr00ve 03-29-2006 05:16 PM

Quote:

Originally Posted by hueofwind
But both two machines, for the security reason, root are disabled for login. In their sshd_config file

no root through ssh ok


Quote:

Originally Posted by hueofwind
But the problem is none of the two machines supports root login, which means if I ssh login to target machine then use rsync, I may not have access right to some directories on source machine.

smth like >
rsync -a -e ssh source/ root@remotemachine.com:/path/to/destination/
will not work because before the user is recognized by rsync it is prohibited by sshd right?

so instead what about doing it in this way (just an idea):

sshd at source allows port to be forwarded to whichever is the backup destination + ssh client at the destination is configured to accept the forwarded port
rsync runs locally on source and creates a backup
then through nc & the forwarded port backup file is being transfered to the target machine

do you think this would work in a cron script?


All times are GMT -5. The time now is 09:38 AM.