Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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.


share|improve this question

migrated from May 23 '11 at 20:22

This question came from our site for professional and enthusiast programmers.

Also the rsync_password is an actual filename and stores the password on 1 line. – Anonymous May 23 '11 at 17:02
We can't ignore $DESTINATION. Is it using the rsync protocol, or rsync over rsh/ssh? – Gilles May 23 '11 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 '11 at 21:17
up vote 2 down vote accepted

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

share|improve this answer

Your Answer


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.