I'm trying to validate rsync via sshd's authorized_keys file.
The problem is I can't manage to execute rsync from the validating script.
Here's my authorized_keys file:
command="/home/username/Desktop/valrsync username" ssh-rsa AAAA [...]
Here's the valrsync script attempted differently each time:
Test 1 –
$SSH_ORIGINAL_COMMAND
Output –
$ rsync [...] / username@remotemachine:/
/home/username/Desktop/valrsync: line 2: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]
And, more importantly, Test 2 –
#!/usr/bin/python
import os
os.system(os.getenv('SSH_ORIGINAL_COMMAND'))
Output (running rsync from the local machine and getting the output of valrsync
on the remote machine) –
$ rsync [...] / username@remotemachine:/
sh: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]
I understand that rsync somehow spawns an instance of itself at the remote machine, and obviously that instance is not referred when I attempt to execute the rsync command via the script. rsync is not installed on the server, and I know it shouldn't be.
Now the question is, what can I do about it (except maybe installing rsync on the server…?)
Best Answer
The error you're receiving is
rsync: command not found
. This typically implies that your$PATH
environment variable is not set correctly. Using your first test, explicitly setPATH
to include the directory where the rsync command is installed. For example:Make sure to make the scrip executable (
chmod 755 valrsync
).All this assumes that rsync is in fact installed on the target system.