Skip to content

Instantly share code, notes, and snippets.

@rangerz
Created March 10, 2020 00:16
Show Gist options
  • Save rangerz/9e83514acf32ec4b094d0f16ce618ff8 to your computer and use it in GitHub Desktop.
Save rangerz/9e83514acf32ec4b094d0f16ce618ff8 to your computer and use it in GitHub Desktop.
SSH with Password Parameter
#!/usr/bin/expect
# Install for MacOSX
# brew install expect
# touch /usr/local/bin/exssh
# chmod +x /usr/local/bin/exssh
set timeout 30
set userhost [lindex $argv 0]
set password [lindex $argv 1]
spawn ssh $userhost
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "$password\n"}
"Password:"
{send "$password\n"}
"*#"
{}
"*$"
{}
"*~"
{}
}
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment