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...?)

link|improve this question
feedback

1 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 set PATH to include the directory where the rsync command is installed. For example:

#!/bin/sh

PATH=/usr/local/bin:$PATH
export PATH

$SSH_ORIGINAL_COMMAND

Make sure to make the scrip executable (chmod 755 valrsync).

All this assumes that rsync is in fact installed on the target system.

link|improve this answer
Thank you for your replay. Is the only way to solve this is to install rsync on the target machine? – Mark Jul 7 '11 at 20:20
2  
Yes, you need to have rsync installed on both the source and destination machine. Rsync needs to run on both ends of the connection (because otherwise, what is rsync talking to?). – larsks Jul 7 '11 at 20:45
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.