☰ Categories

Linux: Passing a password with rsync using expect

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 username@servernameorip:/pathonremoteserver/directory /localdirectory; expect “*?assword:*” {send “userpasswordr”; interact};’