Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm creating a cron job to keep two dirs in sync. I'm using rsync. I'm running an rsync daemon. I read the manual and it says:

   RSYNC_PASSWORD
          Setting  RSYNC_PASSWORD  to  the required password allows you to
          run authenticated rsync connections to an rsync  daemon  without
          user  intervention. Note that this does not supply a password to
          a shell transport such as ssh.

   USER or LOGNAME
          The USER or LOGNAME environment variables are used to  determine
          the  default  username  sent  to an rsync daemon.  If neither is
          set, the username defaults to 'nobody'

I have something like:

#!/bin/bash
USER=name
RSYNC_PASSWORD=pass
DEST="myhost::mymodule"

/usr/bin/rsync -rltvvv . $DEST

I also tried exporting (dangerous, I know) USER and RSYNC_PASSWORD. I also tried with LOGNAME. Nothing works. Am I doing this correctly?

EDIT (for clarification)

I am using rsync version 2.6.9 under linux.

This command works:

/usr/bin/rsync -rltvvv . myuser@myhost::mymodule

I am prompted for the password and when I type it in, the transfer begins.

This is the error I get when trying via the script:

opening tcp connection to myhost port 873
opening connection using --server -vvvltr . mymodule
@ERROR: auth failed on module mymodule
rsync error: error starting client-server protocol (code 5) at main.c(1383) [sender=2.6.9]
_exit_cleanup(code=5, file=main.c, line=1383): about to call exit(5)
share|improve this question
    
What kind of error message, if any, do you get? Can you run it manually? –  pehrs Mar 29 '10 at 8:32
    
Sorry about that. I've edited the question. –  d-_-b Mar 29 '10 at 9:31
    
Well, if nothing else rsync actually manages to read something it believes to be a password. Otherwise you would have been prompted for one. –  andol Mar 29 '10 at 11:20
    
And that got me thinking. I put a declare -x in the script before the rsync command, and LOGNAME and USER are being set by bash I presume. –  d-_-b Mar 30 '10 at 2:44

2 Answers 2

up vote 2 down vote accepted

Have you tried something like:

rsync -rltvvv --password-file=/root/secret . rsync://user@host::dest
share|improve this answer
    
Yup tried that one too. –  d-_-b Mar 29 '10 at 8:10
    
Since I thought I didn't know what was going on with the environment, I tried this again. However, the destination format was slightly different: rsync -rltvvv --password-file=/root/secret . user@host::dest –  d-_-b Mar 30 '10 at 2:50

Use export RSYNC_PASSWORD=pass instead of RSYNC_PASSWORD=pass.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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