版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/qq_32590631/article/details/81208218
#!/usr/bin/expect
set salt [lindex $argv 0]
set password 123456 #跳板机密码
set username myname #跳板机用户名
set server [email protected] #你的服务器名例
set serverpass mypass #你的服务器密码
spawn ssh $username
expect {
"*yes/no*" {
send "yes\n";
exp_continue;
}
"Password:" {
send "$password$salt\n";
exp_continue;
}
}
expect {
"huangkaikang*" {
send "ssh $server\r";
exp_continue;
}
"*password:" {
send "$serverpass\r";
}
}
interact
这里用到了 expect脚本,mac下应该是自带的,如果没有的话百度搜一下怎么安装,这里就不介绍了,有问题欢迎留言