Rsync – maintain ‘root’ permission on another machine

permissionsrsync

I'm just trying to copy a directory from one home server to another, both running Ubuntu (9.04 and 9.10), using rsync. The trouble I'm having is that some of the files in the directory (and subdirectories) are owned by root. The main administrator account on both machines is 'ben', so running this on the old server:

rsync -v -u -a -p -t -rsh=ssh --stats --progress source/ ben@newserver:/dest

Prompts me for ben@newserver's password, copies source/ but all the permissions are 'ben' at the new destination. Running this using sudo means I have access to root's files, but on the other end ben can't write them as belonging to root. Sending to root@newserver asks for root's password, which Ubuntu doesn't give you.

Can anyone explain simply how to do this? Thanks 🙂

Best Answer

You can set up SSH keys, and place your public key in root's ~root/.ssh/authorized_keys2 file on newserver. That way you can do the entire process as root.

Alternativly you can set root's password via:

sudo passwd root

But SSH keys are more secure and (IMHO) more convenient.