1賬號密碼方式: 保存登錄命令文件 /var/www/ssh/xxx.txt
spawn ssh -p 22 root@192.168.0.2
expect {
"yes/no" {send "yes\r";exp_continue;}
"*password:*" { send "$PASSWORD\r" }
}
interact
2 跳板機
spawn ssh work@192.168.0.2 -i /Users/hufeng/yinse
expect "*login*" {send "ssh work@10.10.11.135\r"}
expect "*login*" {send "sudo su - root\r"}
interact