SSH Expect Script #!/usr/bin/expect --
set ipaddr [lindex $argv 0]
set pass "mypassword"
set en "enable pass"
set stars [string repeat "*" [string length $en]]
set timeout -1
spawn ssh -k -t -2 -4 -a -q -x \
-p 22 \
-l user1 \
-o StrictHostKeyChecking=no \
-o Compression=no \
-o CheckHostIP=no \
-o PasswordAuthentication=yes \
-o PubkeyAuthentication=no \
-o RhostsRSAAuthentication=no \
-o RSAAuthentication=no \
$ipaddr
match_max 100000
expect -exact "user1@$ipaddr's password: "
send -- "$pass\r"
expect -exact "\r
Type help or '?' for a list of available commands.\r"
expect -exact "> "
send -- "en\r"
expect -exact "en\r
Password: "
send -- "$en"
expect -exact "$stars"
send -- "\r"
expect -exact "\r"
expect -exact "# "
set CTRLX \030
interact {
-reset $CTRLX {exec kill -STOP [pid]}
}
|