14

I have a user, supersecretuser, that is in the sudo group, but doesn't have sudo access. Is there something else that needs to be done to give this user sudo access?

$ ssh supersecretuser@myserver
supersecretuser@myserver:~$ groups
supersecretuser adm cdrom sudo dip plugdev lpadmin sambashare
supersecretuser@myserver:~$ sudo vim install.sh 
[sudo] password for supersecretuser: 
supersecretuser is not in the sudoers file.  This incident will be reported.

supersecretuser is the user we setup when doing the Ubuntu install.

  • 4
    Did supersecretuser log out and back in (or at least start a new login shell e.g. su - supersecretuser) since being added to the sudo group? – steeldriver Sep 8 '14 at 17:14
  • When I ssh in as supersecretuser, I can see that it is in the sudo group. Is there something else I need to do to log out? Added ssh into server to question. – Jay Mitchell Sep 8 '14 at 17:15
  • If you have another superuser, I would try adding suspersecretuser to the sudo group again. sudo adduser supersecretuser sudo. You might get error like user is already in group sudo, but its worth a shot. – Dan Sep 8 '14 at 18:05
8

Since you error message says your user is not in the sudoers file, could you please check your /etc/sudoers file, see if there is such a line:

%sudo   ALL=(ALL:ALL) ALL

If this line is missing, users in the sudo group will not be sudoers. Edit the file using visudo command (checks for correct synthax and locks the file).

You can also try to add a customized line like this:

root    ALL=(ALL:ALL) ALL

Replace root with your username, reboot, and try if it works.

  • I can't sudo to see this file to say this is 100% the problem. However, based on our chef script that we use on other servers, I can see we aren't adding supersecretuser user to /etc/sudoers. – Jay Mitchell Sep 8 '14 at 20:52
  • Thanks a lot for the answer, I had sudo and admin record but they were not prefixed with a %. – berezovskyi Oct 1 '15 at 9:18
6

As per your conversation with @steeldriver in the comments, my guess is that your user isn't logged off.

The easiest way to make sure that the supersecretuser has logged off is to type into terminal, as another user, who.

When doing so, I get output like this:

mitch@quartz:~$ who
mitch    :0           2014-09-08 09:49 (:0)
mitch    pts/0        2014-09-08 13:18 (:0.0)

I only see myself. Similarly, typing w into a terminal shows me who all is logged on and what they're doing:

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
mitch    :0       :0               09:49   ?xdm?  29:08   0.11s init --user
mitch    pts/0    :0.0             13:18    5.00s  0.06s  0.01s w

You can STOP your other user, (SSU I'll call it) with the following command:

pkill -STOP -u SSU

However, truthfully, the easiest solution would be to just reboot the system if that's possible.

  • Rebooted the server, and I don't have sudo access. – Jay Mitchell Sep 8 '14 at 17:40
  • So you lost the ability for your user to ssh into the server? – Mitch Sep 8 '14 at 17:41
  • Sorry, updated comment. Can still ssh into the server, just not sudo access. – Jay Mitchell Sep 8 '14 at 17:42
  • Can you update the original post with the method you used to grant sudo access to the user? – Mitch Sep 8 '14 at 17:44
  • supersecretuser is the user we setup when doing the Ubuntu install. – Jay Mitchell Sep 8 '14 at 18:00
0

The easiest way to add a supersecretuser to sufo group is sudo gpasswd -a supersecretuser sudo and have supersecretuser log out/back in; but if you have lost the ability to sudo, I'm afraid you'll have to reinstall.

-1

After you have checked that file privileges are right:

-r--r----- 1 root root x x x x:x /etc/sudoers

You most probably have lost the s-bit on file executable, it should read:

-rwsr-xr-x 2 root root x x x  x /usr/bin/sudo

if it doesn't: with root privileges give `

chmod u+s /usr/bin/sudo

and you should be okay.. unless you know you have altered the sudoers file yourself! :)

  • 3
    -1 Issues with the file permissions of the sudo binary and sudoers configuration result in different error messages than those in the question. They would literally refer to inappropriate file permissions. – David Foerster Jan 11 '16 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.