I have a redhat enterprise linux that I am trying to configure for sudo, it is a personal machine and I dont care that much about relaxing the security settings.
I have the following two users, one is member of sba and teel groups and the other one is member sba group:
Now I want to give sudo permissions to these two users so that they could execute any command using sudo without the need to specify a password. To do so I edited the /etc/sudoers file (it was not present at the beginning, I created the file) and added the following lines to it:
pre: sba, teel
bash-4.1$ sudo cat /etc/sudoers
%admin ALL=(ALL) NOPASSWD: ALL
%teel ALL=(ALL) NOPASSWD: ALL
%sudo ALL=(ALL) NOPASSWD: ALL
%sba ALL=(ALL) NOPASSWD: ALL
mtpre ALL=(ALL) NOPASSWD: ALL
pre ALL=(ALL) NOPASSWD: ALL
The mtpre user can use sudo but need to enter password when using sudo and the pre user cannot use sudo at all.
If I do a ls -al using the mtpre for the sudoers file I get:
[pre@machine1 ~]$ sudo cat /etc/sudoers
Sorry, user pre is not allowed to execute '/bin/cat /etc/sudoers' as root on machine1.
Do you see any problem in the sudoers file (I used visudo to edit it and I am sure that syntactically it is fine as visudo did not complain about it) or anywhere that can cause this peculiar issue? Do you know any solution or any means of diagnosing the problem?
bash-4.1$ ls -al /etc/sudoers
-r--r----- 1 root root 519 Mar 30 23:05 /etc/sudoers