如何在 Mac OS X (Yosemite) 上使用指令建立 ssh 連線終端捷徑

如何在 Mac OS X (Yosemite) 上使用指令建立 ssh 連線終端捷徑

在我的 Windows PC 上,我有一個 Putty 批次文件,它連接到我的 Pi (SSH - Openelec)、進行身份驗證root、終止進程 ( hyperiond),然後再次啟動它。我必須經常使用這個文件,因為hyperion有時會變得非常混亂(至少對我來說)。

簡而言之,它執行以下操作:

Connect to 192...... ; 
Authenticate as root with password ; 
Run the commands: killall hyperiond ; 
and /storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json

我想用我的 Macbook 做同樣的事情。是否可以使用終端機在 Mac 上建立這樣的「批次」檔案?

答案1

是的, Mac 上應該有sh和。ssh

  • 建立文件batch.sh
  • 使其可執行chmod u+x batch.sh

文件內容:

#!/bin/sh
ssh root@192... "killall hyperiond; /storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json"

然後將其運行為./batch.sh.它應該提示輸入密碼並執行批次處理。如果您想刪除密碼,請設定密鑰:

ssh-keygen -t rsa
ssh-copy-id root@192...

相關內容