在 RHEL 服务器上,我想让用户以 root 身份运行命令而无需密码:
# uname -a
Linux foo.com 2.6.32-220.38.1.el6.x86_64 #1 SMP Wed May 15 08:34:56 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m
# visudo
User_Alias FOOEMPLOYEES = someuser
Cmnd_Alias FOOCOMMANDS = /root/bin/fix-permissions
FOOEMPLOYEES ALL = NOPASSWD: FOOCOMMANDS
由于某种原因,系统仍然要求用户输入密码:
$ alias
alias fix-permissions='/root/bin/fix-permissions'
$ fix-permissions
-bash: /root/bin/fix-permissions: Permission denied
$ sudo fix-permissions
[sudo] password for someuser:
为什么sudo
配置可能不起作用?是不是我配置错了?我复制了配置本指南。
答案1
最后一个字符串应该是
FOOEMPLOYEES ALL = (ALL) NOPASSWD: FOOCOMMANDS
来自man sudoers
用户规范的基本结构是“who where=(as_whom)what”