使用iTerm2快捷串連SSH

來源:互聯網
上載者:User

標籤:儲存   fork   eof   好的   com   out   svg   捷徑   fonts   

大家都知道使用iTerm2串連shh 使用命令 ssh -p22 [email protected],然後輸入密碼即可。

但是每次都輸入還是比較麻煩的。iTerm2為我們提供了快捷的方式。三步即可完成此項設定。方法如下:

1,編輯命令文本

樣本:

 

[plain] view plain copy  
  1. #!/usr/bin/expect -f  
  2.   set user root  
  3.   set host 172.16.10.71  
  4.   set password mima123456  
  5.   set timeout -1  
  6.    
  7.   spawn ssh [email protected]$host  
  8.   expect "*assword:*"  
  9.   send "$password\r"  
  10.   interact  
  11.   expect eof  

 

 

按照此樣本,編寫一個文字檔儲存在一個位置即可。

此樣本中沒有指明連接埠號碼,使用的就是ssh預設連接埠 22

如果是其它連接埠號碼,可以如下修改

 

[plain] view plain copy  
  1. #!/usr/bin/expect -f  
  2.   set port 2121  
  3.   set user root  
  4.   set host 172.16.10.71  
  5.   set password mima123456  
  6.   set timeout -1  
  7.    
  8.   spawn ssh -p$port [email protected]$host  
  9.   expect "*assword:*"  
  10.   send "$password\r"  
  11.   interact  
  12.   expect eof  


文法說明:上面的set 是定義變數

 

下方的 spawn是調用命令,在命令中使用上述定義好的變數

 

2,設定調用命令

iTerm -- preferences 開啟設定介面

點左下角 + 增加一個捷徑,

在右側選擇 commond,並在輸入框中 輸入命令檔案的地址

在右側上方給此捷徑起個名字。

這樣就完成了捷徑的設定。

 

3,使用捷徑

啟動iTerm2軟體的時候,會彈出一個選擇捷徑的介面,選擇事先建好的捷徑即可;

已經開啟的iTerm2,在軟體表徵圖上右鍵,然後選擇 new Table 就可以看到事先建好的捷徑。

 

使用iTerm2快捷串連SSH

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.