This question already has an answer here:

I'm trying to backup my linux system (arch linux on a laptop) to a remote computer on the same network using ssh (or NFS). I use rsync extensively to backup my /home directory to the remote computer over ssh and NFS with no issues whatsoever. What I want to do is run the rsync command on the laptop within a script and copy all of the contents of / (excluding some directories of course, that I already have figured out) to the remote computer.

The issue I'm having is about permissions. I have disabled root login on the ssh server (openssh, running on an ubuntu server 12.04 computer) and I disabled password authentication and enable rsa key login so I can run the backup scripts automatically using cron on the laptop. Now, for me to able to copy all of the system's files under /* (on the laptop) I need to run rsync as root. Doing that introduces a problem since I'm not able to access the ssh server as root. If I try to do it over NFS i get another permision problem since the root user isn't allowed to access the NFS mount, as my regular user is.

I'm writting here so I can get suggestion on how to solve this problem. I would prefer to do it over ssh since it usually works a lot faster for me, but I'm willing to use NFS or even samba (haven't tried that one) if no other thing works.

marked as duplicate by slm, jasonwryan, Anthon, Rahul Patil, Chris Down Nov 2 '13 at 14:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You could setup a set of ssh keys for root to use. – slm Nov 1 '13 at 23:18
  • Wow, I never even though about that. Didn't think it was possible. I'm going to try it right away. thx – volotec Nov 1 '13 at 23:37
  • Yes you can create keys that are job specific too, they don't have to be dedicated to a particular user. Think if them as more for forming relationships than anything else. – slm Nov 1 '13 at 23:38
  • The duplicate I highlighted shows how you can use authorized_keys file to limit the scope of the shared key too. So the key is only used for rsync and nothing else. – slm Nov 1 '13 at 23:47

Ok so the problem is that your acting as root and root doesn't have keys.

sudo su

then copy the keys over to your backup server.


rsync [stick your options here] / user@backup-server:/path/to/backups

  • Please keep everything on 1 answer. It's OK to edit your original answer if you've learned new info about the Q, or delete the original answer if it's way off. – slm Nov 1 '13 at 23:39
  • rsync -aAX --delete --rsh="ssh -p22 -i ~/.ssh/key-identity" will work pretty well too – coteyr Nov 1 '13 at 23:40
  • 1
    I was going to delete the bad answer in a moment :P – coteyr Nov 1 '13 at 23:41
  • move that into your answer, use comments to refine the answer, not to extend it. – slm Nov 1 '13 at 23:41

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