公司有两重账户,可以使用expect自动登录,代码如下
代码语言:javascript复制#!/usr/bin/expect -f
set ip [lindex $argv [expr $argc-1]]
set user yinzihao
set host $ip
set password pwd1
set bot_password pwd2
set timeout -1
spawn ssh $user@$host
expect {
"es/no" { send "yesr";exp_continue }
"assword" { send "$passwordr"}
}
expect "service" {send "su - botr"}
expect "assword" {send "$bot_passwordr";interact}
expect eof


