iterm2 儲存ssh賬號自動連線

2021-10-01 13:26:52 字數 1313 閱讀 3001

作為一名coder,我們經常需要連線伺服器進行一些操作,然而冗長的ssh密碼登入屬實有些繁瑣。如果你使用了終端工具iterm2,便可以事半功倍!

iterm2具有很多優點:

智慧型選中,雙擊選中,三擊選中整行,四擊智慧型選中;

全文查詢command + f

視窗垂直command + d、水平command + shift + d拆分;

command + ;自動補齊命令

記錄歷史輸入命令command + shift + h等等。

官網位址

1. expect指令碼

首先,我們寫乙個expect 指令碼,放在/usr/local/bin目錄下,

cd /usr/local/bin
建立expect 指令碼檔案,

touch iterm2login.exp
vim iterm2login.exp,編輯指令碼內容,內容如下,

#!/usr/bin/expect

set timeout 30

spawn ssh [lindex $ar** 0]@[lindex $ar** 1]

expect

"password:"

}interact

wq 儲存退出,然後還有最後一步。 給指令碼新增讀寫許可權,在當前目錄執行

sudo chmod -r 777 iterm2login.exp
注意,如果沒有給指令碼新增許可權,你可能會提示以下報錯

permission denied: iterm2login.exp

ok,指令碼完成。

2 配置profile

command + o開啟profile,配置send text at start如下,

iterm2login.exp username ipaddress password
如,

iterm2login.exp root 192.168.1.1 test123
iterm2login.exp後面為三個引數。

iTerm2 儲存密碼

iterm2 儲存密碼 1.編輯如下並儲存檔案至任意目錄,例如檔名為demo,儲存在 users documents item2目錄下。set user set host set password spawn ssh user host expect assword send password r ...

iTerm2的自動補全

開啟 終端 輸入cd oh my zsh plugins,回車 接著輸入mkdir incr,建立乙個名為 incr 的資料夾,方便管理 接著在終端中輸入chmod 777 oh my zsh plugins incr incr 0.2.zsh,賦予該檔案777許可權 接著輸入vim zshrc,然...

iTerm2儲存登入密碼

安裝 略過 安裝 在終端分別執行下邊的命令 configure make make install 這樣就安裝完了,一般不會出問題,安裝完成後,執行下邊的命令檢查是否安裝成功 sshpass h 出現下邊的這些提示就是安裝成功了 3 準備密碼 讓sshpass使用ssh密碼,需要先將密碼儲存在乙個檔...