iterm2 連接服務器保存


profiles =》open profiles => edit profiles 

1:如圖每一連接信息保存單獨的文件   

 

 

 

set PORT 22
set HOST 10.***.***.**
set USER ********
set PASSWORD ********

spawn ssh -p $PORT $USER@$HOST
expect {
        "yes/no" {send "yes\r";exp_continue;}
         "*password:*" { send "$PASSWORD\r" }
        }
interact

2:保存一個sh腳本,賬號密碼已參數形式傳參

expect  ~/Desktop/tzq/iterm2_config/item2Login.sh 端口 用戶名 ip地址 密碼

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

3.對於經常變更密碼,對2進行了改良

expect  /Users/ONE/Desktop/tzq/iterm2_config/item2Loginip.sh ip地址

#!/usr/bin/expect

set timeout 30
spawn ssh -p 端口 用戶名@[lindex $argv 0]
expect {
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "密碼\n"}
}
interact

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM