3

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.

volotec
  • 205
  • 1
    You could setup a set of ssh keys for root to use. – slm Nov 01 '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 01 '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 01 '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 01 '13 at 23:47

1 Answers1

1

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

sudo su
ssh-keygen

then copy the keys over to your backup server.

Finally,

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

coteyr
  • 4,310
  • 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 01 '13 at 23:39
  • rsync -aAX --delete --rsh="ssh -p22 -i ~/.ssh/key-identity" will work pretty well too – coteyr Nov 01 '13 at 23:40
  • 1
    I was going to delete the bad answer in a moment :P – coteyr Nov 01 '13 at 23:41
  • move that into your answer, use comments to refine the answer, not to extend it. – slm Nov 01 '13 at 23:41