我已授予组权限以通过 sudo 运行某些命令而无需密码。当其中一个用户打错字或运行错误的命令时,系统会提示他们输入密码,然后他们会收到错误消息。这让用户感到困惑,所以我只想显示一个错误而不是提示他们输入密码。这可能吗?
这是我的 sudoers 文件的示例:
%mygroup ALL=(ALL) NOPASSWD:/usr/local/bin/myscript.sh *
Run Code Online (Sandbox Code Playgroud)
当他们运行错误的脚本时的示例:
# sudo /usr/local/bin/otherscript.sh
[sudo] password for user:
Sorry, user user is not allowed to execute '/usr/local/bin/otherscript.sh' as root on <hostname>.
Run Code Online (Sandbox Code Playgroud)
期望的输出:
Sorry, user user is not allowed to execute '/usr/local/bin/otherscript.sh' as root on <hostname>. Please check the command and try again.
Run Code Online (Sandbox Code Playgroud)
注意缺少密码提示。
我的谷歌福失败了我,只有在当用户不要求输入密码返回的结果是允许运行的命令。
sudo ×1