We have a LDAP server and lots working servers. Our user's info are in LDAP . But sudoers list is stored in /etc/sudoers. Now the question is, how to store sudoers list in LDAP so that there is a center control of it?
We are using Fedora 12 on both LDAP server and working servers.
3 Answers
Follow the official instructions from README.LDAP, and the sudoers.ldap manual page.
- Make sure
sudois built with LDAP support. - Update the LDAP schema.
- Import
sudoersfile into LDAP. - Configure the
sudoersservice innsswitch.conf.
Add sudo entry like below
dn: ou=sudoers,ou=people,dc=example,dc=com
ou: sudoers
objectClass: top
objectClass: organizationalUnit
dn: cn=sudogroup,ou=sudoers,ou=people,dc=example,dc=com
objectClass: top
objectClass: sudoRole
cn: sudogroup
sudoUser: thomas
sudoHost: ALL
sudoRunAs: ALL
sudoCommand: ALLAdd sudoers_base in ldap.conf for client.
sudoers_base ou=sudoers,ou=people,dc=example,dc=com& Edit /etc/nsswitch.conf like below
sudoers : files ldap 1 These instructions assume you're using OpenLDAP. Some details may be specific to Arch Linux.
- Make sure
sudois built with LDAP support. (see README.LDAP or this) - Add the sudo schema to the LDAP server by editing
slapd.confto addinclude /etc/openldap/schema/sudo.schema. Note that this file must be copied from/usr/share/doc/sudo/schema.OpenLDAP(see README.LDAP). - Per README.LDAP, direct the LDAP server to index the attribute
sudoUserby adding the lineindex sudoUser eqtoslapd.conf, and restart the LDAP server. Add the ou=SUDOers container to the database. This can be done by passing in the following via
ldapadd:dn: ou=SUDOers,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: SUDOersConvert the existing
sudoersfile to LDIF format withcvtsudoersadd it to the database withldapadd(see README.LDAP). The configuration could, of course, be generated from scratch instead.- Creat (or edit)
ldap.conf(/etc/openldap/ldap.confon Arch) on the client to addsudoers_base ou=SUDOers,dc=example,dc=comto make sudo LDAP-aware (seesudoers.ldap). Depending on your LDAP configuration, it may be necessary to set various LDAP options as well; sudo's syntax for setting options may be different than your LDAP implementation, so the same information may need to be provided twice. - Edit
sudoersservice innsswitch.confto besudoers: files ldap, or tosudoers: files sssif caching withSSSD(seesudoers.ldap manual). If caching w/ SSSD, the necessary entries will need to be added to sssd.conf (and on systems running systemdsssd-sudo.socketmust be enabled (see manual page for SSSD-SUDO))