Can I include a password in my rsync call?

I am using rsync to update my static website. Currently cd

located in the local directory of the website and running the command rsync

and then entering the password on the next line. I saved my call rsync

to a text snippet (so it _rs

just expands to my call). Is there a way to use something like a flag -p

at the end and include a password too?

My call looks like this:

rsync -avzh -e ssh * foo@foo.org:"/home/foo/public_html/"

+2


source to share


2 answers


One option is to use a public / private key pair, see How to auto rsync with ssh without password



Or you can try using Expect

+2


source


An answer to this question with a direct answer to the question may be helpful 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/" "charly@chaplin.com:/project/htdocs/site/"
expect "password:"
send "$PASSPH\n"
expect "#"

      

+1


source







All Articles