rsync to a remote NAS without password


Recently I spent considerable time trying to perfect the commands to run a cron job to remotely backup /hhd/movie to my Plex server. I could do it interactively by entering a password. But password free proved to be a problem.

creating a ssh public key is normally quite easy with


On enigma boxes ssh works differently
dropbearkey -t rsa -f ~/.ssh/id_rsa
results in:-
Generating 2048 bit rsa key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6L4+KMydWuT1UwDbPFRZsyP6uuQ3vD3IB26gKVHBi7k1fUlCbk/gHg9/RPpK9BG5D37QBNsaCbHn6/3JpbzlGUVpZLi6zTha3MFXMSg4QoolS3Bq1Z0IrixmCBvurOn6Ap9aLRYprom/IDev2sg02OOsK5b26N2iq9doIkNjcGmz5kX6OvPGuxuUgjR0hDtFB3R9pnOuGk/TDhagRscF+U7/yAIrMT+aaSmTIOfkJWKRGwLlFhqkvn+brkBK794y8LFEY61rEnIQWgYZfikXwGOxwa21K7nW/AeynESMf//aiNtb7l8JtNEbKClFpenlP7BIWVHpEFbk74ny1sNj [email protected]
Fingerprint: sha1!! 22:23:6f:f5:79:ab:27:74:06:79:c9:05:c9:28:3a:00:c6:2d:88:de

Copy the text from on-screen display of the public key but ignore the fingerprint line. Do it now; you'll not get the chance again. It gets scrambled in id_rsa.

Login to your server and in the receiving home directory of the account will be a .ssh folder (if you've already run ssh-keygen there).

Use nano to edit .ssh/authorized_keys and add the portion from ssh-rsa .... [email protected] ([email protected] in my case) on a line beneath any content already there. Save and exit.

Now from your enigma2 box you can ssh <user>@<remote ip address> - substituting as appropriate.

The next final wrinkle for rsync to work is not easily found.

The dropbear version of ssh doesn't know where the keys are. (A bit like me sometimes!)

Use the line
-e "ssh -i /home/root/.ssh/id_rsa"
in your rsync call. -e says execute the stuff between quotes.

I have a cron running nightly that runs this command. note the full colon after the IP address and the server remote file location.

rsync  -truv --protect-args --exclude={'*.txt','*.cuts','*.eit','*.ap','*.nfo','*.sc','*.pkl','*.pdf'} -e "ssh -i /home/root/.ssh/id_rsa" /hdd/movie/ "[email protected]:/volume1/Plex/Library/TV Programmes"

--exclude stop dross like nfo and txt files being saved (if you've got torrent stuff on your box like me!)

Finally I made an executable called
headed by #!/bin/sh
with the rsync line to follow. Saved and made executable by
chmod 700
all that remains is to set up cron. I'll leave that you.

NOTE: after saving this I noticed that *. m e t a (without the spaces) in the exclude section was edited by this site and shown as *.**** and that would nicely defeat any rsync backup. Add it back by hand if you need it.
Last edited: