为什么我不能通过sudo要求输入密码?

时间:2017-09-28 21:40:19

标签: amazon-ec2 passwords sudo

这是我在新的ubuntu ec2盒子上的sudoers文件。为什么sudo su仍然需要密码?

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) PASSWD:ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) PASSWD:ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) PASSWD:ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

有某种延迟吗?你是否认为"来源"它或类似的事情就像你用bashrc文件做的那样?为什么sudo su要求输入密码这么困难?

编辑: 按this链接运行:

sudo passwd ubuntu
sudo perl -pi -e 's/^(ubuntu.*)NOPASSWD:(.*)/$1$2/' /etc/sudoers

不起作用,甚至不更改sudoers文件。

1 个答案:

答案 0 :(得分:0)

尝试删除以下三个位置的PASSWD:ALL

# User privilege specification
root    ALL=(ALL:ALL) 

# Members of the admin group may gain root privileges
%admin ALL=(ALL) 

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL)