Rsync --password-file Not Working

6,223

--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:
6,223

Related videos on Youtube

Darren
Author by

Darren

Currently developing with Java, React Redux (JavaScript), and Oracle. In the past I've developed with NodeJS, PHP, MySQL, PostgreSQL, Redis, Memcached, and Angular. I'm pretty nifty implementing clients from the backend controller layer to the JavaScript/HTML/CSS frontend layer.

Updated on September 18, 2022

Comments

  • Darren
    Darren over 1 year

    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

    • Admin
      Admin almost 13 years
      Also the rsync_password is an actual filename and stores the password on 1 line.
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 13 years
      We can't ignore $DESTINATION. Is it using the rsync protocol, or rsync over rsh/ssh?
    • Darren
      Darren almost 13 years
      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.