Linux: Passing a password with rsync using expect
February 19, 2014
Using ssh keys is always one of the safest ways to connect rsync through ssh.
Here is an alternate less secure way to use rsync when in a pinch.
Install expect
Run the following command:
expect -c ‘spawn rsync -e ssh -avz [email protected]:/pathonremoteserver/directory /localdirectory; expect “*?assword:*” {send “userpasswordr”; interact};’