rsync permission problems in /mnt/local

Status
Not open for further replies.

toraride

Dabbler
Joined
Sep 1, 2016
Messages
24
This is continuation of this topic: https://forums.freenas.org/index.php?threads/root-user-missing-root-ssh-known_hosts.46331/ where I am giving up on trying to store public and private keys in my .ssh and instead defining a location for generated keys to connect to a server.

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:

Code:
rsync -avzP -e ssh -i /mnt/local/ root@192.168.9.114:/DataVolume/shares/NASBackup


This script requires manual authorization, which is why I created a public key, that I stored in /mnt/local/.backup/authorized_keys.pub on the local machine. I then created a new .sh script that contains the following:

Code:
rsync -avzP -e '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:

Code:
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 http://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


The main problem in the error is the permission denied on the /mnt/local folder that I cant figure out. I am logged in as root when I execute the .sh file(s). But whatever reason the second .sh file keeps throwing the "permissions denied" error. What should I do from here?

EDIT: The public key is in the .ssh folder under authorized_keys on the remote server I want to send the backup to. But the script fails before it gets that far, due to permission errors locally.

What is rsync in the eyes of the system? What does it run as and is it possible that rsync itself does not have the required permissions?
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478

toraride

Dabbler
Joined
Sep 1, 2016
Messages
24
Yeah this system is really ruined!
I added tripple verbose (-vvv) and removed the -P as you said as well. The output is the following:

Code:
rsync: -: unknown option
rsync error: syntax or usage error (code 1) at main.c(1436) [client=3.0.9]
[client] _exit_cleanup(code=1, file=main.c, line=1436): about to call exit(1)


Looks like rsync itself is broken, as I am following several tutorials for rsync as well as the main documentation. This NAS needs a fresh start.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Yeah this system is really ruined!
I added tripple verbose (-vvv) and removed the -P as you said as well. The output is the following:

Code:
rsync: -: unknown option
rsync error: syntax or usage error (code 1) at main.c(1436) [client=3.0.9]
[client] _exit_cleanup(code=1, file=main.c, line=1436): about to call exit(1)


Looks like rsync itself is broken, as I am following several tutorials for rsync as well as the main documentation. This NAS needs a fresh start.
It's easy to get frustrated with rsync...

I think you've just got a stray dash ('-') on your rsync command line; post your command and we'll give it a look.

EDIT: ...and I can't find any reference to a '-vvv' verbosity command option; try just '-v' or '--verbose' instead.
 
Last edited:

toraride

Dabbler
Joined
Sep 1, 2016
Messages
24
I think I found my problem:

This script:

Code:
rsync -avvvz -e "ssh -i /mnt/local/.backup/keys" /mnt/local/lala00/
ssh -l root -p 22 192.168.9.114:/DataVolume/shares/NASBackup


Gives the following output:


ssh: Could not resolve hostname 192.168.9.114:/DataVolume/shares/NASBackup: hostname nor servname provided, or not known


If I run nslookup on 192.168.9.114

Code:
nslookup 192.168.9.114
Server:	 8.8.8.8
Address:   8.8.8.8#53
** server can't find 114.9.168.192.in-addr.arpa.: NXDOMAIN


Which is quite odd, considering I can log in via ssh just fine if I execute it myself typing it on command line. But running it as an .sh wont work? From my understand this again goes back to the config files.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I think I found my problem:

This script:

Code:
rsync -avvvz -e "ssh -i /mnt/local/.backup/keys" /mnt/local/lala00/
ssh -l root -p 22 192.168.9.114:/DataVolume/shares/NASBackup


Gives the following output:


ssh: Could not resolve hostname 192.168.9.114:/DataVolume/shares/NASBackup: hostname nor servname provided, or not known


If I run nslookup on 192.168.9.114

Code:
nslookup 192.168.9.114
Server:	 8.8.8.8
Address:   8.8.8.8#53
** server can't find 114.9.168.192.in-addr.arpa.: NXDOMAIN


Which is quite odd, considering I can log in via ssh just fine if I execute it myself typing it on command line. But running it as an .sh wont work? From my understand this again goes back to the config files.
I don't follow what you're trying to do...

It looks like you have an incomplete rsync command and an ssh command...

Are you having problems setting up SSH with public keys?

Your rsync command has the triple-v option, which I don't believe is correct, and lacks a destination specifier.

With SSH, you connect to a server (either using a hostname or an IP address) on a port (usually 22) - but you seem to be specifying an IP-based path to a dataset.

If I were you, I'd try to get your rsync command working while logged on to a shell session. Once you know it works, then you can automate it with chron or whatever.
 

toraride

Dabbler
Joined
Sep 1, 2016
Messages
24
rsync -avvvz -e "ssh -i /mnt/local/.backup/keys" /mnt/local/lala00/
ssh -l root -p 22 192.168.9.114:/DataVolume/shares/NASBackup

What I am trying to do with the above is:

rsync + vvv because I am getting a large verbose output to help me handle what is going on behind the scenes. I am invoking -e to tell it to use a private key on a custom path, that the receiving servers pub key can read, since I did that part already, and I am then taking a local directory and pushing it to a local network ip via ssh.

Problem is, the NAS cannot resolve the hostname because it once again relies on /etc/ssh/ssh_config to be working. And this goes back to my main problem of that nothing in the NAS is writeable under the config folders, such as ~/.ssh/, (which is also why I am specifying a custom key path).
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
rsync -avvvz -e "ssh -i /mnt/local/.backup/keys" /mnt/local/lala00/
ssh -l root -p 22 192.168.9.114:/DataVolume/shares/NASBackup

What I am trying to do with the above is:

rsync + vvv because I am getting a large verbose output to help me handle what is going on behind the scenes. I am invoking -e to tell it to use a private key on a custom path, that the receiving servers pub key can read, since I did that part already, and I am then taking a local directory and pushing it to a local network ip via ssh.

Problem is, the NAS cannot resolve the hostname because it once again relies on /etc/ssh/ssh_config to be working. And this goes back to my main problem of that nothing in the NAS is writeable under the config folders, such as ~/.ssh/, (which is also why I am specifying a custom key path).
Forgive me, but you don't seem to understand either the rsync or ssh commands very well.

Along with options, rsync requires two command-line parameters: source and target dataset specifiers. You're missing the target dataset specifier.

Your ssh command can't copy anything as it doesn't have the required command line parameters to do so. 192.168.9.114 is a local, class-C network IP address and doesn't require a DNS lookup. Your mistake is in appending path information to it. To attach the server at that IP address, you need only enter:

ssh -l root -p 22 192.168.9.114

This should start a command shell on the host at 192.168.9.114, after prompting you for a password.

You can execute remote commands on that server after giving ssh enough information to connect to it, for example:

ssh -l root -p 22 192.168.9.114 'cp /home/mystuff/* /mnt/local/homes/bob/mystuff'

...would perform the cp command shown.

You say you can't write to the server's ~./ssh directory. Can you log on the server as root?
 

toraride

Dabbler
Joined
Sep 1, 2016
Messages
24
Problem solved! This is the final script:
rsync -avvvz -e "ssh -i /mnt/local/.backup/keys -o StrictHostKeyChecking=no" /mnt/local 192.168.9.114:/DataVolume/shares/NASBackup

Had to add the stricthost to make it skip authentication in the ~./ssh dir
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Nice :cool:
 
Status
Not open for further replies.
Top