在sudoers文件中使用NOPASSWD作为特定的命令,在其他所有的命令中使用PASSWD

我想configurationsudo,使用户可以在不input密码的情况下运行某些特定命令(为了方便起见),并且可以通过input密码来运行所有其他命令。

这是我的,但这不起作用; 总是需要密码:

Defaults env_reset Defaults timestamp_timeout = 1 root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) NOPASSWD: /usr/sbin/pm-suspend, /usr/bin/apt-get, PASSWD: ALL #includedir /etc/sudoers.d 

请注意,这是一个debian系统,它使用这个将用户添加到“sudo”组方法。

谢谢。

你应该能够做到这样的事情:

 Cmnd_Alias WITHOUTPW = /path/to/cmd1, /path/to/cmd2 Defaults!WITHOUTPW !authenticate