Home > Tech stuff > SSH using expect scripts

SSH using expect scripts

#!/usr/bin/expect -f

set timeout 30

spawn ssh -l USERNAME -o PubkeyAuthentication=no HOSTNAME
expect {
"password" { send "PASSWORD\r"; }}
expect {
"bash" {
send "sudo su - SU_USER\r";
}
"denied" { exit; }}
expect {
"password" { send "PASSWORD\r"; }}
interact;
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment