3

I made a shell backup script that uses Rsync and I am trying to get rid of the password prompt because it will use a CRON to run. I have set my variable in my shell script at:

PASSWORD_FILE=rsync_password

and the password in that file only takes up 1 line.

However when I run (ignore $DESTINATION)

rsync -aRvz tmp $DESTINATION --password-file=$PASSWORD_FILE

It still gives me the prompt. How can I accomplish this? I cannot allow a prompt and I do not want to have to use keys.

Thanks

3
  • Also the rsync_password is an actual filename and stores the password on 1 line.
    – Anonymous
    May 23, 2011 at 17:02
  • We can't ignore $DESTINATION. Is it using the rsync protocol, or rsync over rsh/ssh? May 23, 2011 at 20:23
  • Hi, $DESTINATION has nothing to do with this issue... it is a variable I have populated and the script works fine if I am prompted. This is rsync over SSH.
    – Darren
    May 23, 2011 at 21:17

1 Answer 1

2

--password-file only sets a password if you're using the rsync daemon. It has no effect when using rsync over rsh or ssh.

The recommended authentication method over ssh is to use public keys. It's both the secure method and the simple method. Generate a private key on the client side (ssh-keygen) and run ssh-copy-id to copy it to the server.

If there's an extremely good reason why you're not using ssh keys (hint: there probably isn't), you can use expect to insert the SSH password into the stream. It's not supposed to be easy to do, in fact SSH is designed to make this difficult, for good reason (passwords are bad for security, and the way you're using that password makes it particularly exposed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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