Files
val-blog/deploy_pindou.exp
T

46 lines
750 B
Plaintext

#!/usr/bin/expect -f
set timeout 20
set host "gch3n.online"
set port "11022"
set user "gch3n"
set password {@wt65gt1900}
log_user 1
spawn ssh -p $port -o PreferredAuthentications=password -o PubkeyAuthentication=no $user@$host
expect {
-re "password:" {
send "$password\r"
exp_continue
}
-re "Permission denied" {
puts "\nPassword rejected by server"
exit 1
}
-re "\\$ " {
send "whoami\r"
}
-re "# " {
send "whoami\r"
}
timeout {
puts "\nConnection timeout"
exit 1
}
}
expect {
-re "gch3n" {
puts "\nLogin successful!"
send "exit\r"
}
timeout {
puts "\nCommand timeout"
exit 1
}
}
expect eof