Created
March 22, 2012 13:00
-
-
Save mvidner/2158225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
# usage: ssh-password mysecret command... | |
# where command is ssh user@machine | |
# or ssh-copy-id user@machine | |
# ... | |
match_max 100000 | |
set timeout -1 | |
set password [lrange $argv 0 0] | |
spawn {*}[lrange $argv 1 end] | |
# Look for passwod prompt | |
expect "*?assword:*" | |
# Send password aka $password | |
send -- "$password\r" | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, my own version. Work well with unknown hosts, skip passphrase check ( can be modified ) and play nicely when command is given so e.g.
ssh root@machine cat /etc/issue
in this case your doesn't work