Created
February 18, 2016 17:07
-
-
Save joaompinto/eff3453a5cfabbf564c8 to your computer and use it in GitHub Desktop.
Connect to system with expect
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 -f | |
| set target [lindex $argv 0]; | |
| set timeout 60 | |
| # Request the login password | |
| stty -echo | |
| send_user -- "Password for $target: " | |
| expect_user -re "(.*)\n" | |
| send_user "\n" | |
| stty echo | |
| set pass $expect_out(1,string) | |
| #Connect using ssh | |
| set timeout 2 | |
| spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no $target | |
| expect "?assword:" | |
| send "$pass\n" | |
| expect "$" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment