Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am setting up a backup server on which I want to run rsync over ssh to backup content on other servers every night. I would like to set up ssh keys to make it password-less, but I want to preserve ownership of files and permissions. There are a number of users on the server to be backed up which won't all exist on the backup server.

What would be the best way to do this? I guess the backup job will need to connect as root to , but I don't want to enable root ssh access on the servers.

thanks for any tips,


ps, all servers are running UBUNTU Server 12.04 LTS and are behind a university firewall.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You cannot. Linux REQUIRES you to have root access to save a file as any user other than yourself. The ONLY workaround is to tarball it and then transfer the tarball to the server.

share|improve this answer
As a side note, you can enable root access over ssh on the server so long as you set authorized_keys to only allow a specific command (rsync in this case). Use the command option in authorized_keys to set a specific key to only allow a specific command such as /usr/bin/rsync. However, due to the security of ssh keys, if they have access to the root keys, you've got bigger issues on hand. – UtahJarhead Oct 9 '12 at 1:53

If you just don't have root ssh access, but have sudo(8) rights on the machine, you can do it.

For example, by putting username ALL= NOPASSWD:/usr/bin/rsync in /etc/sudoers on remote host and doing:

rsync -a -e "ssh" --rsync-path="sudo rsync" localdir/

See this answer for details and more options of doing it.

Also, since users don't already exist on remote, you'll need to use --numeric-ids on your rsync line so they'll get preserved (but you'll only see their usernames and groups once you sync /etc/passwd and /etc/group, of course)

share|improve this answer

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.