不在 sudoers 檔案中.此事將被報告解決方法,修改centos自定義使用者帳號免密使用命令
阿新 • • 發佈:2020-08-18
建立一個 centos帳號,帳號名為 yyee,使用yyee帳號登入,執行sudo vi命令時(執行其它命令也有同樣情況),報錯:linc 不在 sudoers 檔案中。此事將被報告。
此情情況的解決方案:
切換到root帳號
su root
修改 /etc/sudoers 檔案,此檔案只讀,許可權為440,先修改成777
chmod 777 /etc/sudoers
vi /etc/sudoers
將yyee帳號新增到配置檔案,在root ALL=(ALL) ALL下面新增一行yyee ALL=(ALL) ALL
root ALL=(ALL) ALL
yyee ALL=(ALL) ALL
這樣就可以使用 yyee帳號操作命令了,但是使用sudo 操作部分命令,需要輸入密碼,不方便,可以設定yyee帳號使用sudo許可權時,免密執行命令,這在使用Jenkins自動部署與自動釋出非常方便。
解決方法是把yyee ALL=(ALL) ALL 修改成yyee ALL=(ALL) NOPASSWD:ALL
root ALL=(ALL) ALL
yyee ALL=(ALL) NOPASSWD:ALL
然後將 /etc/sudoers 檔案改回440許可權,必須要改回440許可權,不然會提示 yyee is not in the sudoers file. This incident will be reported.
chmod 440 /etc/sudoers