Using expect to pass a password to ssh

cygwin, expect, ssh

Solution

I always used the "proper" solution, but I used expect in other situations.

Here I found following suggestion:

#!/usr/local/bin/expect
spawn  sftp  -b cmdFile user@yourserver.com
expect "password:"
send "shhh!\n";
interact

Problem

How can I use expect to send a password to an ssh connection. say the password was p@ssword and the ssh command was ssh me@127.0.0.1 What would I do with expect to a make it input the password when it says me@127.0.0.1's password: ? The proper action of using an SSH key pair isn't an option because I would have to use ssh (scp) to put the key on the server, which would ask for a password.

Original source