3

Trying to remove password on sudo. My current 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"


root    ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo   ALL=(ALL:ALL) ALL


vidar ALL=(ALL) NOPASSWD: ALL

I quit, open new terminal (or even reboot), but password is still required for sudo. User is member of sudo group.

What can possibly be happening?

Vidar
  • 41

4 Answers4

5

You don't have to reboot for the change to take effect.

You are missing the :ALL part of the entry.

Change from:

vidar ALL=(ALL) NOPASSWD: ALL

change to:

vidar ALL=(ALL:ALL) NOPASSWD: ALL
L. D. James
  • 25,444
3

The order of the entries in the sudoers file is important. You should also check the directory /etc/sudoers.d, because entries on this directory may be overwriting what you trying to do on sudoers.

You can also check the /etc/sudoers.d/README for more information.

Eduardo
  • 131
  • 3
1

Just to elaborate on and complement the answer provided by @Eduardo , the order of the entries in the sudoers file is important not only because of possible duplicate entries, but also for group rules that a later group rule may overwrite any previous rules specified for users that belong to the group.

For example, a sudoers file like this

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

Members of the admin group may gain root privileges

%admin ALL=(ALL) ALL

Allow members of group sudo to execute any command

%sudo ALL=(ALL:ALL) ALL

may have problems when userX belongs to either admin or sudo group, as the NOPASSWD: rule will be overwritten by rules applied to the admin and/or sudo groups, thus your NOPASSWD: rule will be lost.

So it's safer to put individual user rules in the sudoers.d directory since those will be loaded later than the default group rules.

0

I had similar problem. Adding my changes in /etc/sudoers.d/anotherfile made it work.

visusdo will open /etc/sudoers for editing but in my case i also added /etc/sudoers.d/anotherfile as the changes in sudoers file were not enabled.

FredyK
  • 101