linux - 为什么在sudoers中配置了NOPASSWD却还需输入密码?

【字号: 日期:2022-08-08浏览:42作者:雯心

问题描述

这是我的sudoers的配置文件

Defaultsenv_resetDefaultsmail_badpassDefaultssecure_path='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'# Host alias specificationHost_Alias TX=12x.xxx.xxx.xx9# User alias specification# Cmnd alias specification# User privilege specificationroot ALL=(ALL:ALL) ALLwww_remote TX=(root) NOPASSWD:/bin/chown# Allow members of group sudo to execute any command%sudo ALL=(ALL:ALL) ALL# See sudoers(5) for more information on '#include' directives:#includedir /etc/sudoers.d

在远程登录到www_remote后执行sudo chown仍需输入密码

[root@VM_xx_xx_centos ~]# sudo -u apache ssh xxx.xxx -l www_remoteLinux iZ...Z 3.2.0-4-amd64 #1 SMP Debian 3.2.86-1 x86_64Welcome to aliyun Elastic Compute Service!Last login: Sun May 14 17:55:32 2017 from 12x.xxx.xxx.xx9www_remote@iZ...Z:~$ ls -l总用量 0-rw-r--r-- 1 www-data www_remote 0 5月 14 16:38 testwww_remote@iZ...Z:~$ sudo chown :www-data test [sudo] password for www_remote: www_remote 无权在 iZ281fkjotsZ 上运行 sudo。此事将被报告。

如果是www_remote ALL=(root) NOPASSWD:/bin/chown 的话就可以正常执行指令.

我的配置到底错在哪了?

问题解答

回答1:

sudo su root回答2:

把'www_remote'那行挪到文件的最后,不然%sudo会把这条给覆盖掉。

相关文章: