1

I have a .sh file that I can manually trigger to run a backup to a remote server on the local network. It looks like this:

rsync -avzP -e ssh -i /mnt/local/ [email protected]:/DataVolume/shares/NASBackup

This requires authorization, which is why I created a public key, that I stored in /mnt/local/.backup/authorized_keys.pub

I then created a new .sh script that contains the following

rsync -avzP 'ssh -i /mnt/local/.backup/authorized_keys -o StrictHostKeyChecking=no' /mnt/local 192.168.9.114:/DataVolume/shares/NASBackup

It throws a permission denied error. Specifically the following:

rsync: change_dir "/mnt/local/.backup//ssh -i /mnt/local/.backup" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1053) [sender=3.0.9]
./backup-start-new.sh: /mnt/local: Permission denied

The reason for the location of the .pub key on the local machine I attempt to run rsync from is due to that my authorized keys folder is unwriteable, so I placed my keys elsewhere. On the remote server, the .pub key is placed in ~/.ssh/authorized_keys

The main problem in the error is the permission denied on the /mnt/local folder that I cant figure out. The originating server is a FreeNAS server.

4
  • 1
    You forgot -e. Commented Oct 11, 2016 at 10:39
  • I added -e for it to look like this: rsync -avzP -e 'ssh -i /mnt/local/.backup/authorized_keys -o StrictHostKeyChecking=no' /mnt/local 192.168.9.114:/DataVolume/shares/NASBackup and now it throws the following error: Use "rsync --daemon --help" to see the daemon-mode command-line options. Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation. See rsync.samba.org for updates, bug reports, and answers rsync error: syntax or usage error (code 1) at main.c(1504) [Receiver=3.0.9] ./backup-start-new.sh: /mnt/local: Permission denied Commented Oct 11, 2016 at 10:46
  • You need to use your private file for connecting. (-i ...) or simply copy it to ~/.ssh. And check if you have permission for /mnt/local/ Commented Oct 11, 2016 at 10:56
  • I dont understand? Use my private file for connecting? The permissions to /mnt/local is where I am getting confused, as I am not sure why the rsync .sh script when running WITH the public key argument is failing. Commented Oct 11, 2016 at 11:01

1 Answer 1

1

Is ~/.ssh/authorized_keys permissions set to 0600 and ~/.ssh to 0700?

SSH is very picky with permissions on the files.

9
  • On local server or on remote server? Commented Oct 11, 2016 at 10:53
  • On remote, authorized keys must contain the public key form your local machine.
    – Navarro
    Commented Oct 11, 2016 at 10:53
  • Just to clarify, you must generate a SSH key pair on your local machine, then insert the public key on the remote server ~/.ssh/authorized_keys, those directories must have the permissions set as I told you before. Also, it is tricky when you copy/paste depending on the terminal you are using, since public keys must be only one line and they tend to be pasted as several. Take care of this.
    – Navarro
    Commented Oct 11, 2016 at 10:57
  • Yes, but my error starts before it even connects. It is a local machine permission settings that prevents me from even getting to the remote machine. I for some reason do not via rsync have permission to /mnt/local to run it Commented Oct 11, 2016 at 10:58
  • The public key on the remote server is one line, and I copied it into the ~/.ssh/authorized_keys file, after generating it on my local machine. I used this tutorial for generating: troy.jdmz.net/rsync/index.html Commented Oct 11, 2016 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .