[ACCEPTED]-Using expect to pass a password to ssh-expect
I always used the "proper" solution, but 2 I used expect in other situations.
Here I found 1 following suggestion:
#!/usr/local/bin/expect
spawn sftp -b cmdFile user@yourserver.com
expect "password:"
send "shhh!\n";
interact
Would it not be easier to use public key 5 authentication and use a key with no passphrase?
As 4 the user on the source machine do this to 3 make an RSA key
ssh-keygen -t rsa
Now copy ~/.ssh/id_rsa.pub 2 to the target machine and append it to the 1 authorized_keys file of the target user
Your quickest way forward (unless you want 11 to become a Tcl expert, which would be... unusual... in 10 2009) is probably to use autoexpect
. Here's the man 9 page:
http://expect.nist.gov/example/autoexpect.man.html
In short, fire up autoexpect
, run your ssh session, finish 8 up what you need to do, stop autoexpecting 7 and then beat your keyboard over the resulting 6 mess until it works :) I'm assuming you 5 don't need anything more than a quick hack 4 to get your keys sorted out and then, well 3 it sounds like you know the score already 2 with that.
And there's this question which already contains 1 an example close to what you seek.
Cygwin has autoexpect just not in the bin 6 package. run setup.exe and search for expect 5 and check the source checkbox. you will 4 see the resulting tree in /usr/src and in 3 there there is a expect/expect/examples 2 directory. in there lives a copy of the 1 autoexpect script.
Key solution will not work... because the 5 keys have to be readable only by the person 4 running ssh. On xp you cannot create key 3 structure with the correct permissions. So 2 ssh will not read them. This may have changed, but 1 last i checked it still not not work.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.