天天看點

item2實作ssh的免密登入

編寫expect腳本

1 建立腳本(腳本位置沒有明确要求)

touch ssh-info.sh
           

2 腳本内容

#!/usr/bin/expect

set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "[lindex $argv 3]\n"}
}
interact
           

item2工具設定

1 打開設定

item2實作ssh的免密登入

2 參數配置

/Users/miaogaolin/Documents/ssh-info.sh [端口号] [使用者名] [伺服器IP] ['密碼']
           
item2實作ssh的免密登入

3 開始連接配接

方式一:command + o

方式二:如下圖

item2實作ssh的免密登入

繼續閱讀