1

I have multiple Ubuntu Linux hosts that need to connect to Active Directory for user management (unfortunately an actual LDAP server was not an option here...) and have configured Winbind to handle authentication, and my %sudoers group entry works fine:

## Allow AD members of the service group restricted user access to that account
%sudoers ALL=(ALL:ALL) NOPASSWD:ALL

I have allowed password authentication in the ssh config and have added the following entry to my sudoers file for the account:

%service ALL=(service:service) NOPASSWD:ALL

This doesn't even find the group even though the sudoers group and the service groups are at the same level in the directory tree on the AD server. When I do this:

%domain.local\\service ALL=(ALL:ALL) NOPASSWD:ALL

...members of the service group are able to log in and have full sudo rights, including root which is unacceptable, and already covered by the sudoers group and entry. Alternatively when I do this:

%domain.local\\service ALL=(service:service) NOPASSWD:ALL

...members are unable to sudo to any user. As for the service user, here is the /etc/passwd entry for the service user:

service:x:1001:16777230::/opt/service:/bin/bash

Per the Sudoers Man Page this last entry should probably work, but for some reason it doesn't. Also, the %service should also probably cover both local and AD provided membership but it doesn't seem to. When I create this user since there is already a group in the directory server named service here is how I am creating the service user account:

useradd -d /opt/service -g service service

Here is the output of sudo -l for a member of the group:

[user.test@server ~]$ sudo -l
Matching Defaults entries for user.test 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

User user.test may run the following commands on this host:
    (service : service) NOPASSWD: /opt/service

What am i missing here?

  • "This doesn't even allow members to log in" ... sudoers has nothing to do with login via SSH. For each of these settings, what is the output of sudo -l for an applicable user? – muru May 10 '16 at 22:51
  • true. my mistake. corrected. thanks. – spyderdyne May 10 '16 at 22:54
  • [user.test@aaamecldtbwp02 ~]$ sudo -l service sudo: list: command not found – spyderdyne May 10 '16 at 23:08
  • No, just sudo -l without a command, and edit your question to include more information, please. – muru May 10 '16 at 23:10
1

I found the solution. We needed to set the login shell and path to the sudoers entry for the service user's home like so:

%domain.local\\service ALL=(service) NOPASSWD:/bin/bash, /opt/service/*

Now we are able to enter the following to become the service user:

$ sudo -i -u service
$ whoami
service
$ pwd
/opt/service

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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