forked from Ziply-DBA/UnixDBA
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate_password.sh
More file actions
32 lines (26 loc) · 783 Bytes
/
Copy pathvalidate_password.sh
File metadata and controls
32 lines (26 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/expect
# This script is adapted from:
# https://www.pantz.org/software/expect/expect_examples_and_tips.html
set timeout 9
set username [lindex $argv 0]
set password [lindex $argv 1]
set hostname [lindex $argv 2]
log_user 0
if {[llength $argv] == 0} {
send_user "Usage: scriptname username \'password\' hostname\n"
exit 1
}
spawn ssh -q -o StrictHostKeyChecking=no $username@$hostname
expect {
timeout { send_user "\nFailed to get password prompt for $hostname\n"; exit 1 }
eof { send_user "\nSSH failure for $hostname\n"; exit 1 }
"*assword"
}
send "$password\r"
expect {
timeout { send_user "\nLogin for hostname $hostname failed. Password incorrect.\n"; exit 1}
"*\$ "
}
send_user "\nPassword for hostname $hostname is correct\n"
send "exit\r"
close