I’m ‘expect’ing something lol

Supposed you just ran a script that would change your password
on all the servers you’re admin’ng and you don’t have full confidence
that changes have been implemented throughout. Or you may just
want to check if all these servers contain the same password for
your username. Now you can, for just $5 a month you also get
an abundant supply of unlimited(while supply lasts) post-its.

======start script======
#!/usr/bin/expect -f
#script to check if passwords

#line below used for testing
#spawn rm .ssh/known_hosts
set server [lindex $argv 0]
set timeout -1
spawn ssh -o NumberOfPasswordPrompts=1 $server >/dev/null
match_max 100000
expect “Are you sure you want to continue connecting (yes/no)? ”
send — “yes\r”
expect “password:”
send — “currentpass\r”
set timeout 2
#send — “exit\r”
expect eof
=====end script========

Save to file ‘check-pass.exp’ then run this from cli:
# rm CHECK-RESULTS; for i in `cat servers.txt`; do ./check-pass.exp $i; if [$? -eq 0 ]; then echo

“$i PASSWD is CURRENT” >>CHECK-RESULTS; else echo “$i FAILS” >>CHECK-RESULTS;fi;done

Or in a script:
#!/usr/bin/bash
rm CHECK-RESULTS
for i in `cat servers.txt`; do
./check-pass.exp $i
if [ $? -eq 0]; then
echo “$i PASSWORD is CURRENT” >>CHECK-RESULTS
else
echo “$i FAIL” >>CHECK-RESULTS
fi
done

#NOTE TO SELF: PASSWORD, REMOVE, WHEN DONE

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code:

This site uses Akismet to reduce spam. Learn how your comment data is processed.