Answers:
来自man sudoers:
NOPASSWD and PASSWD
By default, sudo requires that a user authenticate him or herself
before running a command. This behavior can be modified via the
NOPASSWD tag. Like a Runas_Spec, the NOPASSWD tag sets a default for
the commands that follow it in the Cmnd_Spec_List. Conversely, the
PASSWD tag can be used to reverse things. For example:
ray rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm
would allow the user ray to run /bin/kill, /bin/ls, and /usr/bin/lprm
as root on the machine rushmore without authenticating himself.
另外一个标记是ALL
,以允许用户ray在没有密码的情况下在任何主机上运行任何命令,您可以使用:
ray ALL= NOPASSWD: ALL
/etc/sudoers
。您无需像普通配置文件一样编辑此文件,而应使用visudo
命令(以root用户身份)。