搜尋此網誌

2015年10月30日 星期五

讓 授權的使用者 不需知道 root 密碼 就能執行 root 任務 的指令 Sudo


以下方法在 Production 環境有資安的風險。

Open a Terminal window. Type in sudo visudo 
Add the following line to the END of the file (if not at the end it can be nullified by later entries):

開啟終端機畫面,直接輸入 sudo visudo
至檔案最尾端,編輯加入以下:

indy ALL=NOPASSWD: ALL

存檔完,還要關閉 Terminal window 生效。

重新登入後, 輸入 sudo bash ,就能讓 user 不用知道 root 密碼的情境下轉為 root 身份了。 



另外、以下方式是避免每次 sudo 都要打密碼的麻煩:

約第 26 行  找到以下
%sudo   ALL=(ALL:ALL) ALL
改成
%sudo   ALL=(ALL:ALL) NOPASSWD:ALL

沒有留言:

張貼留言

搜尋此網誌