%20%E4%B8%8A%E4%BD%BF%E7%94%A8%E6%8C%87%E4%BB%A4%E5%BB%BA%E7%AB%8B%20ssh%20%E9%80%A3%E7%B7%9A%E7%B5%82%E7%AB%AF%E6%8D%B7%E5%BE%91.png)
在我的 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...