#!/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