1账号密码方式: 保存登录命令文件 /var/www/ssh/xxx.txt
spawn ssh -p 22 [email protected]
expect {
"yes/no" {send "yes\r";exp_continue;}
"*password:*" { send "$PASSWORD\r" }
}
interact
2 跳板机
spawn ssh [email protected] -i /Users/hufeng/yinse
expect "*login*" {send "ssh [email protected]\r"}
expect "*login*" {send "sudo su - root\r"}
interact