Maiasaura
Maiasaura

Reputation: 32986

Can I include a password in my rsync call?

I use rsync to update my static website. I currently cd to the local website directory, and run the rsync command, and then enter the password in the next line. I've saved my rsync call into a text snippet (such that _rs just expands to my call). Is there way to use something like a -p flag at the end and include the password too?

My call looks like this:

rsync -avzh -e ssh * [email protected]:"/home/foo/public_html/"

Upvotes: 2

Views: 7417

Answers (2)

Darryl Hebbes
Darryl Hebbes

Reputation: 1028

Answering this with a direct answer to the question, may be useful in less secure scenarios.

#!/usr/bin/expect -f

set PASSPH "123456"
send_user "\n"
stty -echo

spawn rsync -apv -e ssh "/Volumes/Macintosh HD/Users/charliechaplin/test/" "[email protected]:/project/htdocs/site/"
expect "password:"
send "$PASSPH\n"
expect "#"

Upvotes: 3

Anton Bessonov
Anton Bessonov

Reputation: 9813

One of option is use public/private key pair, see How to auto rsync with ssh passwordless

Or you can try use Expect

Upvotes: 2

Related Questions