0

We are setting up a server with centos 6.10, when setting up a user with sudo, we discovered that sudo never asks for password. Setting up another user with the same (full) sudo rights, it is asked for password.

I have tried both to set up the users explicitely and to add it to the wheel group with the same behaviour. I have also set the password timeout to 0 with no changes.

[root@noaspare ~]# su mysql 
bash-4.1$ ls -l ls: 
cannot open directory.: Permission denied 
bash-4.1$ sudo ls -l
[sudo] password for mysql: (Ctrl-C)
bash-4.1$ exit 

[root@noaspare ~]# su ssi 
[ssi@noaspare /root]$ ls 
ls: cannot open directory .: Permission denied 

[ssi@noaspare /root]$ sudo ls 
anaconda-ks.cfg  install.log  install.log.syslog  rpmbuild

sudo -l for the ssi gives:

Matching Defaults entries for ssi on this host:
    requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE 
INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", 
env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME >    LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET 
 XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin,
timestamp_timeout=0


User ssi may run the following commands on this host:

Sudoers entry:
RunAsUsers: ALL
Commands:
ALL

Any idea why this configuration does not ask for a password? The only difference I can see between the two users is their shell, but I cannot see why that should matter.

The only line specific to the user is

ssi       ALL=(ALL)       ALL
3
  • Look for a NOPASSWD entry in your sudoers file(s). You can then link that config entry to the user account which works without prompting for a password.
    – Haxiel
    Commented Mar 23, 2020 at 14:49
  • That was my first idea as well, but no trace of any NOPASSWD in the sudoers.. Commented Mar 24, 2020 at 7:09
  • Okay. Just to be clear, you should also check for additional sudoers files added with #include or #includedir. Another thing to check is if the behaviour only occurs with sudo -l or sudo -v. If that's the case, you can check the listpw or verifypw option. See the man page for details.
    – Haxiel
    Commented Mar 24, 2020 at 10:36

1 Answer 1

0

It turned out the solution was simple and logical when we just found out what was the problem: The user had in some way no password defined (however that could happen). After setting a password for the user, sudo also worked as expected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .