Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a server to do remote backups through SSH (pull). How can I copy the /root directory without logging in as root user?

share|improve this question
up vote 2 down vote accepted

Add your backup user to a completely new group created for this purpose, and make that group the group-owner of everything under /root

chgrp -R newgroup /root

or make a small script that tars up /root to STDOUT (say, /usr/local/bin/tar-up-root) and configure your sudoers to allow your backup user to run the script passwordless:

backupuser  ALL=(root) NOPASSWD: /usr/local/bin/tar-up-root

and then

ssh backupuser@host-to-backup "/usr/local/bin/tar-up-root" > /var/tmp/remote-root-backup.tar

or run a script from cron, as root, on the host to be backed up, which tars up root to a file owned by the backup user and mode 600 (you don't want anyone else to be able to read this tarfile, or you've weakened security on /root), then have backupuser just scp this file off the host to be backed up.

Any of those any good?

share|improve this answer
Thanks for the advices, will probably use all of them for different problems :) – Znarkus Feb 1 '11 at 15:31

Add your backup user to the wheel group, and it will have root privileges. Or add it to a less privileged group and give that group read access to the /root directory and all the files in it.

share|improve this answer
Not to raise a stink, but what makes you think that wheel group membership automatically grants such powers? – MadHatter Feb 1 '11 at 12:19
There is no wheel group by default in Ubuntu – Znarkus Feb 1 '11 at 13:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.