Last active
December 5, 2016 20:56
-
-
Save badstreff/91340213ee0c39653e1fbf62e3487897 to your computer and use it in GitHub Desktop.
What did I just write...
This file contains 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 password "PASSWORDGOESHERE" | |
set r 0 | |
spawn ssh -oStrictHostKeyChecking=no admin@localhost exit | |
expect "assword:" { | |
send "$password\r" | |
expect "assword:" { | |
set r 1 | |
} | |
} | |
# If we didn't get prompted twice the password should be correct | |
if {$r == 0} { | |
send_user "Password Set Correctly" | |
exit 0 | |
} | |
# If we got prompted twice go ahead and check the other possible account | |
if {$r == 1} { | |
set r 0 | |
spawn ssh -oStrictHostKeyChecking=no administrator@localhost exit | |
expect "assword:" { | |
send "$password\r" | |
expect "assword:" { | |
set r 1 | |
} | |
} | |
} | |
# If we didn't get prompted twice the password should be correct | |
if {$r == 0} { | |
send_user "Password Set Correctly" | |
exit 0 | |
} | |
send_user "Password Not Set" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment