Sudo is not woking on my centos7.3

General support questions
xq10907
Posts: 27
Joined: 2017/08/08 03:33:41

Sudo is not woking on my centos7.3

Post by xq10907 » 2017/08/08 08:38:57

Hello guys

I added local user test to /etc/sudoers via visudo as follows

Code: Select all

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
test    ALL=(ALL)       ALL
then su to test,run command as root get error says the user in not in sudoers file,please give some suggestion,thanks

Code: Select all

[root@ark-centos-smb4 ~]# su - test
Last login: Tue Aug  8 01:03:48 PDT 2017 on pts/0
[test@ark-centos-smb4 ~]$ sudo ls /root/
[sudo] password for test:
test is not in the sudoers file.  This incident will be reported.

simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

Re: Sudo is not woking on my centos7.3

Post by simon_lefisch » 2017/08/08 14:55:59

Remove the "test" user from the sudoers file and run the command below as root to give the user sudo priveldges:

Code: Select all

usermod -aG sudo <username>
Replace username with the correct user
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Sudo is not woking on my centos7.3

Post by TrevorH » 2017/08/08 15:59:20

And replace "sudo" with "wheel" as there is no sudo group in CentOS.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

xq10907
Posts: 27
Joined: 2017/08/08 03:33:41

Re: Sudo is not woking on my centos7.3

Post by xq10907 » 2017/08/09 01:56:17

Still not working after adding test to wheel group,see below commands,it really frustrate me,i referred to posts on web,it seems doesn't involved complicated configuration,my centos has samba,ssssd,kerberos configured,joined windows domain via realm, not sure these will affect sudo's functioning
Thanks

Code: Select all

[test@ark-centos-smb4 ~]$ groups test
test : bin wheel
[test@ark-centos-smb4 ~]$ sudo ls /root/
[sudo] password for test:
test is not in the sudoers file.  This incident will be reported.
collected /var/log/secure contents while running above sudo command with test user,no idea what was complain?

Code: Select all

Aug  9 00:30:53 ark-centos-smb4 sudo: pam_unix(sudo:auth): authentication failure; logname=test uid=39984 euid=0 tty=/dev/pts/2 ruser=test rhost=  user=test
Aug  9 00:30:56 ark-centos-smb4 sudo: pam_unix(sudo:auth): conversation failed
Aug  9 00:30:56 ark-centos-smb4 sudo: pam_unix(sudo:auth): auth could not identify password for [test]
Aug  9 00:30:56 ark-centos-smb4 sudo:    test : pam_authenticate: Conversation error ; TTY=pts/2 ; PWD=/home/test ; USER=root ; COMMAND=/usr/bin/ls /root
Aug  9 00:30:56 ark-centos-smb4 sudo:    test : user NOT in sudoers ; TTY=pts/2 ; PWD=/home/test ; USER=root ; COMMAND=/usr/bin/ls /root
Aug  9 00:31:02 ark-centos-smb4 sudo:    test : user NOT in sudoers ; TTY=pts/2 ; PWD=/home/test ; USER=root ; COMMAND=/usr/bin/ls /root

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Sudo is not woking on my centos7.3

Post by TrevorH » 2017/08/09 08:30:13

Does it have a password set?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

xq10907
Posts: 27
Joined: 2017/08/08 03:33:41

Re: Sudo is not woking on my centos7.3

Post by xq10907 » 2017/08/09 08:32:51

TrevorH wrote:Does it have a password set?
yes,I tried login centos with test's password it's working

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Sudo is not woking on my centos7.3

Post by TrevorH » 2017/08/09 08:41:19

What's the output from ls -laZ /etc/{passwd,shadow}
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

xq10907
Posts: 27
Joined: 2017/08/08 03:33:41

Re: Sudo is not woking on my centos7.3

Post by xq10907 » 2017/08/09 09:12:29

TrevorH wrote:What's the output from ls -laZ /etc/{passwd,shadow}
Here it is

Code: Select all

[root@ark-centos-smb4 ~]# ls -laZ /etc/passwd
-rw-r--r-- root root ?                                /etc/passwd
[root@ark-centos-smb4 ~]#  ls -laZ /etc/shadow
---------- root root ?                                /etc/shadow

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Sudo is not woking on my centos7.3

Post by TrevorH » 2017/08/09 10:02:04

selinux is disabled? :-(
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

xq10907
Posts: 27
Joined: 2017/08/08 03:33:41

Re: Sudo is not woking on my centos7.3

Post by xq10907 » 2017/08/10 02:30:42

TrevorH wrote:selinux is disabled? :-(
Yes should i change selinux to enforcing or permissive? according to web threads,enforcing is default after installation
thanks

Post Reply