我嘗試這樣遠程腳本:慶典 - 運行從本地機器
#!bin/bash
ssh [email protected] 'sudo /etc/init.d/script restart'
但我得到這個錯誤:
sudo: no tty present and no askpass program specified
我怎樣才能運行該腳本?現在,當我需要運行該腳本我做這些步驟:
ssh [email protected]
sudo /etc/init.d/script restart
但我不想手動登錄到遠程服務器中的所有時間,然後重新輸入命令。
我可以寫本地腳本,我可以運行,所以我只需要輸入密碼,它會運行遠程腳本並重新啓動過程?
詢問你的系統管理員給你的特權在沒有密碼的情況下運行'sudo /etc/init.d/script'。如果你是系統管理員,請參閱'man visudo'和'man sudoers' – 2014-09-03 13:28:04