iTerm 使用expect实现自动远程登录,登录跳板机
#!/usr/bin/expect
set timeout 10
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send “<password>\n"}
}
expect “*<服务器名>*" {send "ssh [lindex $argv 3]@[lindex $argv 4]\n"}
expect "*password:" {send "[lindex $argv 5]\n"}
#expect eof
interact
在mac上使用iTerm连接服务器,不能保存密码,通过expect脚本来实现自动密码输入
一般公司内部只能通过跳板机登录,通过上面的脚本可以实现连续登录 ,具体的iTerm配置参考网上其它教程
通过expect脚本还可以实现更复杂的自动化运维
参考:
http://blog.csdn.net/ofengyajie/article/details/17840751

浙公网安备 33010602011771号