#!/usr/bin/expect -f
set username [lrange $argv 0 0]
set password [lrange $argv 1 1]
set ipaddr [lrange $argv 2 2]
set timeout -1
spawn ssh $username@$ipaddr
match_max 100000
expect {
"*?(yes/no)*" { send -- "yes\r" }
"*?assword:*" { send -- "$password\r" }
}
set timeout 10
expect {
"*?assword:*" { send -- "$password\r" }
}
expect "$username*" { send -- "sudo su - \r" }
interact
No comments:
Post a Comment