1SUDOERS.LDAP(5)             BSD File Formats Manual            SUDOERS.LDAP(5)
2

NAME

4     sudoers.ldap — sudo LDAP configuration
5

DESCRIPTION

7     In addition to the standard sudoers file, sudo may be configured via
8     LDAP.  This can be especially useful for synchronizing sudoers in a
9     large, distributed environment.
10
11     Using LDAP for sudoers has several benefits:
12
13     ·  sudo no longer needs to read sudoers in its entirety.  When LDAP is
14        used, there are only two or three LDAP queries per invocation.  This
15        makes it especially fast and particularly usable in LDAP environments.
16
17     ·  sudo no longer exits if there is a typo in sudoers.  It is not possi‐
18        ble to load LDAP data into the server that does not conform to the
19        sudoers schema, so proper syntax is guaranteed.  It is still possible
20        to have typos in a user or host name, but this will not prevent sudo
21        from running.
22
23     ·  It is possible to specify per-entry options that override the global
24        default options.  /etc/sudoers only supports default options and lim‐
25        ited options associated with user/host/commands/aliases.  The syntax
26        is complicated and can be difficult for users to understand.  Placing
27        the options directly in the entry is more natural.
28
29     ·  The visudo program is no longer needed.  visudo provides locking and
30        syntax checking of the /etc/sudoers file.  Since LDAP updates are
31        atomic, locking is no longer necessary.  Because syntax is checked
32        when the data is inserted into LDAP, there is no need for a special‐
33        ized tool to check syntax.
34
35   SUDOers LDAP container
36     The sudoers configuration is contained in the ou=SUDOers LDAP container.
37
38     Sudo first looks for the cn=defaults entry in the SUDOers container.  If
39     found, the multi-valued sudoOption attribute is parsed in the same manner
40     as a global Defaults line in /etc/sudoers.  In the following example, the
41     SSH_AUTH_SOCK variable will be preserved in the environment for all
42     users.
43
44         dn: cn=defaults,ou=SUDOers,dc=my-domain,dc=com
45         objectClass: top
46         objectClass: sudoRole
47         cn: defaults
48         description: Default sudoOption's go here
49         sudoOption: env_keep+=SSH_AUTH_SOCK
50
51     The equivalent of a sudoer in LDAP is a sudoRole.  It consists of the
52     following attributes:
53
54     sudoUser
55           A user name, user ID (prefixed with ‘#’), Unix group name or ID
56           (prefixed with ‘%’ or ‘%#’ respectively), user netgroup (prefixed
57           with ‘+’), or non-Unix group name or ID (prefixed with ‘%:’ or
58           ‘%:#’ respectively).  User netgroups are matched using the user and
59           domain members only; the host member is not used when matching.
60           Non-Unix group support is only available when an appropriate
61           group_plugin is defined in the global defaults sudoRole object.
62
63     sudoHost
64           A host name, IP address, IP network, or host netgroup (prefixed
65           with a ‘+’).  The special value ALL will match any host.  Host net‐
66           groups are matched using the host (both qualified and unqualified)
67           and domain members only; the user member is not used when matching.
68           If a sudoHost entry is preceded by an exclamation point, ‘!’, and
69           the entry matches, the sudoRole in which it resides will be
70           ignored.  Negated sudoHost entries are only supported by version
71           1.8.18 or higher.
72
73     sudoCommand
74           A fully-qualified Unix command name with optional command line
75           arguments, potentially including globbing characters (aka wild
76           cards).  If a command name is preceded by an exclamation point,
77           ‘!’, the user will be prohibited from running that command.
78
79           The built-in command “sudoedit” is used to permit a user to run
80           sudo with the -e option (or as sudoedit).  It may take command line
81           arguments just as a normal command does.  Note that “sudoedit” is a
82           command built into sudo itself and must be specified in without a
83           leading path.
84
85           The special value ALL will match any command.
86
87           If a command name is prefixed with a SHA-2 digest, it will only be
88           allowed if the digest matches.  This may be useful in situations
89           where the user invoking sudo has write access to the command or its
90           parent directory.  The following digest formats are supported:
91           sha224, sha256, sha384 and sha512.  The digest name must be fol‐
92           lowed by a colon (‘:’) and then the actual digest, in either hex or
93           base64 format.  For example, given the following value for sudoCom‐
94           mand:
95
96               sha224:0GomF8mNN3wlDt1HD9XldjJ3SNgpFdbjO1+NsQ /bin/ls
97
98           The user may only run /bin/ls if its sha224 digest matches the
99           specified value.  Command digests are only supported by version
100           1.8.7 or higher.
101
102     sudoOption
103           Identical in function to the global options described above, but
104           specific to the sudoRole in which it resides.
105
106     sudoRunAsUser
107           A user name or uid (prefixed with ‘#’) that commands may be run as
108           or a Unix group (prefixed with a ‘%’) or user netgroup (prefixed
109           with a ‘+’) that contains a list of users that commands may be run
110           as.  The special value ALL will match any user.  If sudoRunAsUser
111           is specified but empty, it will match the invoking user.  If nei‐
112           ther sudoRunAsUser nor sudoRunAsGroup are present, the value of the
113           runas_default sudoOption is used (defaults to root).
114
115           The sudoRunAsUser attribute is only available in sudo versions
116           1.7.0 and higher.  Older versions of sudo use the sudoRunAs
117           attribute instead.
118
119     sudoRunAsGroup
120           A Unix group or gid (prefixed with ‘#’) that commands may be run
121           as.  The special value ALL will match any group.
122
123           The sudoRunAsGroup attribute is only available in sudo versions
124           1.7.0 and higher.
125
126     sudoNotBefore
127           A timestamp in the form yyyymmddHHMMSSZ that can be used to provide
128           a start date/time for when the sudoRole will be valid.  If multiple
129           sudoNotBefore entries are present, the earliest is used.  Note that
130           timestamps must be in Coordinated Universal Time (UTC), not the
131           local timezone.  The minute and seconds portions are optional, but
132           some LDAP servers require that they be present (contrary to the
133           RFC).
134
135           The sudoNotBefore attribute is only available in sudo versions
136           1.7.5 and higher and must be explicitly enabled via the
137           SUDOERS_TIMED option in /etc/sudo-ldap.conf.
138
139     sudoNotAfter
140           A timestamp in the form yyyymmddHHMMSSZ that indicates an expira‐
141           tion date/time, after which the sudoRole will no longer be valid.
142           If multiple sudoNotAfter entries are present, the last one is used.
143           Note that timestamps must be in Coordinated Universal Time (UTC),
144           not the local timezone.  The minute and seconds portions are
145           optional, but some LDAP servers require that they be present (con‐
146           trary to the RFC).
147
148           The sudoNotAfter attribute is only available in sudo versions 1.7.5
149           and higher and must be explicitly enabled via the SUDOERS_TIMED
150           option in /etc/sudo-ldap.conf.
151
152     sudoOrder
153           The sudoRole entries retrieved from the LDAP directory have no
154           inherent order.  The sudoOrder attribute is an integer (or floating
155           point value for LDAP servers that support it) that is used to sort
156           the matching entries.  This allows LDAP-based sudoers entries to
157           more closely mimic the behavior of the sudoers file, where the
158           order of the entries influences the result.  If multiple entries
159           match, the entry with the highest sudoOrder attribute is chosen.
160           This corresponds to the “last match” behavior of the sudoers file.
161           If the sudoOrder attribute is not present, a value of 0 is assumed.
162
163           The sudoOrder attribute is only available in sudo versions 1.7.5
164           and higher.
165
166     Each attribute listed above should contain a single value, but there may
167     be multiple instances of each attribute type.  A sudoRole must contain at
168     least one sudoUser, sudoHost and sudoCommand.
169
170     The following example allows users in group wheel to run any command on
171     any host via sudo:
172
173         dn: cn=%wheel,ou=SUDOers,dc=my-domain,dc=com
174         objectClass: top
175         objectClass: sudoRole
176         cn: %wheel
177         sudoUser: %wheel
178         sudoHost: ALL
179         sudoCommand: ALL
180
181   Anatomy of LDAP sudoers lookup
182     When looking up a sudoer using LDAP there are only two or three LDAP
183     queries per invocation.  The first query is to parse the global options.
184     The second is to match against the user's name and the groups that the
185     user belongs to.  (The special ALL tag is matched in this query too.)  If
186     no match is returned for the user's name and groups, a third query
187     returns all entries containing user netgroups and other non-Unix groups
188     and checks to see if the user belongs to any of them.
189
190     If timed entries are enabled with the SUDOERS_TIMED configuration direc‐
191     tive, the LDAP queries include a sub-filter that limits retrieval to
192     entries that satisfy the time constraints, if any.
193
194     If the NETGROUP_BASE configuration directive is present (see Configuring
195     ldap.conf below), queries are performed to determine the list of net‐
196     groups the user belongs to before the sudoers query.  This makes it pos‐
197     sible to include netgroups in the sudoers query string in the same manner
198     as Unix groups.  The third query mentioned above is not performed unless
199     a group provider plugin is also configured.  The actual LDAP queries per‐
200     formed by sudo are as follows:
201
202     1.   Match all nisNetgroup records with a nisNetgroupTriple containing
203          the user, host and NIS domain.  The query will match
204          nisNetgroupTriple entries with either the short or long form of the
205          host name or no host name specified in the tuple.  If the NIS domain
206          is set, the query will match only match entries that include the
207          domain or for which there is no domain present.  If the NIS domain
208          is not set, a wildcard is used to match any domain name but be aware
209          that the NIS schema used by some LDAP servers may not support wild
210          cards for nisNetgroupTriple.
211
212     2.   Repeated queries are performed to find any nested nisNetgroup
213          records with a memberNisNetgroup entry that refers to an already-
214          matched record.
215
216     For sites with a large number of netgroups, using NETGROUP_BASE can sig‐
217     nificantly speed up sudo's execution time.
218
219   Differences between LDAP and non-LDAP sudoers
220     One of the major differences between LDAP and file-based sudoers is that
221     in LDAP, sudo-specific Aliases are not supported.
222
223     For the most part, there is little need for sudo-specific Aliases.  Unix
224     groups, non-Unix groups (via the group_plugin) or user netgroups can be
225     used in place of User_Aliases and Runas_Aliases.  Host netgroups can be
226     used in place of Host_Aliases.  Since groups and netgroups can also be
227     stored in LDAP there is no real need for sudo-specific aliases.
228
229     There are also some subtle differences in the way sudoers is handled once
230     in LDAP.  Probably the biggest is that according to the RFC, LDAP order‐
231     ing is arbitrary and you cannot expect that Attributes and Entries are
232     returned in any specific order.
233
234     The order in which different entries are applied can be controlled using
235     the sudoOrder attribute, but there is no way to guarantee the order of
236     attributes within a specific entry.  If there are conflicting command
237     rules in an entry, the negative takes precedence.  This is called para‐
238     noid behavior (not necessarily the most specific match).
239
240     Here is an example:
241
242         # /etc/sudoers:
243         # Allow all commands except shell
244         johnny  ALL=(root) ALL,!/bin/sh
245         # Always allows all commands because ALL is matched last
246         puddles ALL=(root) !/bin/sh,ALL
247
248         # LDAP equivalent of johnny
249         # Allows all commands except shell
250         dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com
251         objectClass: sudoRole
252         objectClass: top
253         cn: role1
254         sudoUser: johnny
255         sudoHost: ALL
256         sudoCommand: ALL
257         sudoCommand: !/bin/sh
258
259         # LDAP equivalent of puddles
260         # Notice that even though ALL comes last, it still behaves like
261         # role1 since the LDAP code assumes the more paranoid configuration
262         dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com
263         objectClass: sudoRole
264         objectClass: top
265         cn: role2
266         sudoUser: puddles
267         sudoHost: ALL
268         sudoCommand: !/bin/sh
269         sudoCommand: ALL
270
271     Another difference is that it is not possible to use negation in a
272     sudoUser, sudoRunAsUser or sudoRunAsGroup attribute.  For example, the
273     following attributes do not behave the way one might expect.
274
275         # does not match all but joe
276         # rather, does not match anyone
277         sudoUser: !joe
278
279         # does not match all but joe
280         # rather, matches everyone including Joe
281         sudoUser: ALL
282         sudoUser: !joe
283
284   Converting between file-based and LDAP sudoers
285     The cvtsudoers(1) utility can be used to convert between file-based and
286     LDAP sudoers.  However, there are features in the file-based sudoers that
287     have no equivalent in LDAP-based sudoers (and vice versa).  These cannot
288     be converted automatically.
289
290     For example, a Cmnd_Alias in a sudoers file may be converted to a
291     sudoRole that contains multiple commands.  Multiple users and/or groups
292     may be assigned to the sudoRole.
293
294     Also, host, user, runas and command-based Defaults entries are not sup‐
295     ported.  However, a sudoRole may contain one or more sudoOption
296     attributes which can often serve the same purpose.
297
298     Consider the following sudoers lines:
299
300         Cmnd_Alias PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
301         Defaults!PAGERS noexec
302         alice, bob ALL = ALL
303
304     In this example, alice and bob are allowed to run all commands, but the
305     commands listed in PAGERS will have the noexec flag set, preventing shell
306     escapes.
307
308     When converting this to LDAP, two sudoRole objects can be used:
309
310         dn: cn=PAGERS,ou=SUDOers,dc=my-domain,dc=com
311         objectClass: top
312         objectClass: sudoRole
313         cn: PAGERS
314         sudoUser: alice
315         sudoUser: bob
316         sudoHost: ALL
317         sudoCommand: /usr/bin/more
318         sudoCommand: /usr/bin/pg
319         sudoCommand: /usr/bin/less
320         sudoOption: noexec
321         sudoOrder: 900
322
323         dn: cn=ADMINS,ou=SUDOers,dc=my-domain,dc=com
324         objectClass: top
325         objectClass: sudoRole
326         cn: ADMINS
327         sudoUser: alice
328         sudoUser: bob
329         sudoHost: ALL
330         sudoCommand: ALL
331         sudoOrder: 100
332
333     In the LDAP version, the sudoOrder attribute is used to guarantee that
334     the PAGERS sudoRole with noexec has precedence.  Unlike the sudoers ver‐
335     sion, the LDAP version requires that all users for whom the restriction
336     should apply be assigned to the PAGERS sudoRole.  Using a Unix group or
337     netgroup in PAGERS rather than listing each user would make this easier
338     to maintain.
339
340     Per-user Defaults entries can be emulated by using one or more sudoOption
341     attributes in a sudoRole.  Consider the following sudoers lines:
342
343         User_Alias ADMINS = john, sally
344         Defaults:ADMINS !authenticate
345         ADMINS ALL = (ALL:ALL) ALL
346
347     In this example, john and sally are allowed to run any command as any
348     user or group.
349
350     When converting this to LDAP, we can use a Unix group instead of the
351     User_Alias.
352
353         dn: cn=admins,ou=SUDOers,dc=my-domain,dc=com
354         objectClass: top
355         objectClass: sudoRole
356         cn: admins
357         sudoUser: %admin
358         sudoHost: ALL
359         sudoRunAsUser: ALL
360         sudoRunAsGroup: ALL
361         sudoCommand: ALL
362         sudoOption: !authenticate
363
364     This assumes that users john and sally are members of the “admins” Unix
365     group.
366
367   Sudoers schema
368     In order to use sudo's LDAP support, the sudo schema must be installed on
369     your LDAP server.  In addition, be sure to index the sudoUser attribute.
370
371     Three versions of the schema: one for OpenLDAP servers (schema.OpenLDAP),
372     one for Netscape-derived servers (schema.iPlanet), and one for Microsoft
373     Active Directory (schema.ActiveDirectory) may be found in the sudo dis‐
374     tribution.
375
376     The schema for sudo in OpenLDAP form is also included in the EXAMPLES
377     section.
378
379   Configuring ldap.conf
380     Sudo reads the /etc/sudo-ldap.conf file for LDAP-specific configuration.
381     Typically, this file is shared between different LDAP-aware clients.  As
382     such, most of the settings are not sudo-specific. Note that sudo parses
383     /etc/sudo-ldap.conf itself and may support options that differ from those
384     described in the system's ldap.conf(5) manual.  The path to ldap.conf may
385     be overridden via the ldap_conf plugin argument in sudo.conf(5).
386
387     Also note that on systems using the OpenLDAP libraries, default values
388     specified in /etc/openldap/ldap.conf or the user's .ldaprc files are not
389     used.
390
391     Only those options explicitly listed in /etc/sudo-ldap.conf as being sup‐
392     ported by sudo are honored.  Configuration options are listed below in
393     upper case but are parsed in a case-independent manner.
394
395     Lines beginning with a pound sign (‘#’) are ignored.  Leading white space
396     is removed from the beginning of lines.
397
398     BIND_TIMELIMIT seconds
399           The BIND_TIMELIMIT parameter specifies the amount of time, in sec‐
400           onds, to wait while trying to connect to an LDAP server.  If multi‐
401           ple URIs or HOSTs are specified, this is the amount of time to wait
402           before trying the next one in the list.
403
404     BINDDN DN
405           The BINDDN parameter specifies the identity, in the form of a Dis‐
406           tinguished Name (DN), to use when performing LDAP operations.  If
407           not specified, LDAP operations are performed with an anonymous
408           identity.  By default, most LDAP servers will allow anonymous
409           access.
410
411     BINDPW secret
412           The BINDPW parameter specifies the password to use when performing
413           LDAP operations.  This is typically used in conjunction with the
414           BINDDN parameter.  The secret may be a plain text password or a
415           base64-encoded string with a “base64:” prefix.  For example:
416
417               BINDPW base64:dGVzdA==
418
419           If a plain text password is used, it should be a simple string
420           without quotes.  Plain text passwords may not include the comment
421           character (‘#’) and the escaping of special characters with a back‐
422           slash (‘\’) is not supported.
423
424     DEREF never/searching/finding/always
425           How alias dereferencing is to be performed when searching.  See the
426           ldap.conf(5) manual for a full description of this option.
427
428     HOST name[:port] ...
429           If no URI is specified (see below), the HOST parameter specifies a
430           white space-delimited list of LDAP servers to connect to.  Each
431           host may include an optional port separated by a colon (‘:’).  The
432           HOST parameter is deprecated in favor of the URI specification and
433           is included for backwards compatibility only.
434
435     KRB5_CCNAME file name
436           The path to the Kerberos 5 credential cache to use when authenti‐
437           cating with the remote server.  This option is only relevant when
438           using SASL authentication (see below).
439
440     LDAP_VERSION number
441           The version of the LDAP protocol to use when connecting to the
442           server.  The default value is protocol version 3.
443
444     NETGROUP_BASE base
445           The base DN to use when performing LDAP netgroup queries.  Typi‐
446           cally this is of the form ou=netgroup,dc=my-domain,dc=com for the
447           domain my-domain.com.  Multiple NETGROUP_BASE lines may be speci‐
448           fied, in which case they are queried in the order specified.
449
450           This option can be used to query a user's netgroups directly via
451           LDAP which is usually faster than fetching every sudoRole object
452           containing a sudoUser that begins with a ‘+’ prefix.  The NIS
453           schema used by some LDAP servers need a modification to support
454           querying the nisNetgroup object by its nisNetgroupTriple member.
455           OpenLDAP's slapd requires the following change to the
456           nisNetgroupTriple attribute:
457
458               attributetype ( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple'
459                   DESC 'Netgroup triple'
460                   EQUALITY caseIgnoreIA5Match
461                   SUBSTR caseIgnoreIA5SubstringsMatch
462                   SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
463
464     NETGROUP_SEARCH_FILTER ldap_filter
465           An LDAP filter which is used to restrict the set of records
466           returned when performing an LDAP netgroup query.  Typically, this
467           is of the form attribute=value or
468           (&(attribute=value)(attribute2=value2)).  The default search filter
469           is: objectClass=nisNetgroup.  If ldap_filter is omitted, no search
470           filter will be used.  This option is only when querying netgroups
471           directly via LDAP.
472
473     NETWORK_TIMEOUT seconds
474           An alias for BIND_TIMELIMIT provided for OpenLDAP compatibility.
475
476     PORT port_number
477           If no URI is specified, the PORT parameter specifies the default
478           port to connect to on the LDAP server if a HOST parameter does not
479           specify the port itself.  If no PORT parameter is used, the default
480           is port 389 for LDAP and port 636 for LDAP over TLS (SSL).  The
481           PORT parameter is deprecated in favor of the URI specification and
482           is included for backwards compatibility only.
483
484     ROOTBINDDN DN
485           The ROOTBINDDN parameter specifies the identity, in the form of a
486           Distinguished Name (DN), to use when performing privileged LDAP
487           operations, such as sudoers queries.  The password corresponding to
488           the identity should be stored in the or the path specified by the
489           ldap_secret plugin argument in sudo.conf(5), which defaults to
490           /etc/ldap.secret.  If no ROOTBINDDN is specified, the BINDDN iden‐
491           tity is used (if any).
492
493     ROOTUSE_SASL on/true/yes/off/false/no
494           Enable ROOTUSE_SASL to enable SASL authentication when connecting
495           to an LDAP server from a privileged process, such as sudo.
496
497     SASL_AUTH_ID identity
498           The SASL user name to use when connecting to the LDAP server.  By
499           default, sudo will use an anonymous connection.  This option is
500           only relevant when using SASL authentication.
501
502     SASL_MECH mechanisms
503           A white space-delimited list of SASL authentication mechanisms to
504           use.  By default, sudo will use GSSAPI authentication.
505
506     SASL_SECPROPS none/properties
507           SASL security properties or none for no properties.  See the SASL
508           programmer's manual for details.  This option is only relevant when
509           using SASL authentication.
510
511     SSL on/true/yes/off/false/no
512           If the SSL parameter is set to on, true or yes, TLS (SSL) encryp‐
513           tion is always used when communicating with the LDAP server.  Typi‐
514           cally, this involves connecting to the server on port 636 (ldaps).
515
516     SSL start_tls
517           If the SSL parameter is set to start_tls, the LDAP server connec‐
518           tion is initiated normally and TLS encryption is begun before the
519           bind credentials are sent.  This has the advantage of not requiring
520           a dedicated port for encrypted communications.  This parameter is
521           only supported by LDAP servers that honor the start_tls extension,
522           such as the OpenLDAP and Tivoli Directory servers.
523
524     SUDOERS_BASE base
525           The base DN to use when performing sudo LDAP queries.  Typically
526           this is of the form ou=SUDOers,dc=my-domain,dc=com for the domain
527           my-domain.com.  Multiple SUDOERS_BASE lines may be specified, in
528           which case they are queried in the order specified.
529
530     SUDOERS_DEBUG debug_level
531           This sets the debug level for sudo LDAP queries.  Debugging infor‐
532           mation is printed to the standard error.  A value of 1 results in a
533           moderate amount of debugging information.  A value of 2 shows the
534           results of the matches themselves.  This parameter should not be
535           set in a production environment as the extra information is likely
536           to confuse users.
537
538           The SUDOERS_DEBUG parameter is deprecated and will be removed in a
539           future release.  The same information is now logged via the sudo
540           debugging framework using the “ldap” subsystem at priorities diag
541           and info for debug_level values 1 and 2 respectively.  See the
542           sudo.conf(5) manual for details on how to configure sudo debugging.
543
544     SUDOERS_SEARCH_FILTER ldap_filter
545           An LDAP filter which is used to restrict the set of records
546           returned when performing a sudo LDAP query.  Typically, this is of
547           the form attribute=value or
548           (&(attribute=value)(attribute2=value2)).  The default search filter
549           is: objectClass=sudoRole.  If ldap_filter is omitted, no search
550           filter will be used.
551
552     SUDOERS_TIMED on/true/yes/off/false/no
553           Whether or not to evaluate the sudoNotBefore and sudoNotAfter
554           attributes that implement time-dependent sudoers entries.
555
556     TIMELIMIT seconds
557           The TIMELIMIT parameter specifies the amount of time, in seconds,
558           to wait for a response to an LDAP query.
559
560     TIMEOUT seconds
561           The TIMEOUT parameter specifies the amount of time, in seconds, to
562           wait for a response from the various LDAP APIs.
563
564     TLS_CACERT file name
565           An alias for TLS_CACERTFILE for OpenLDAP compatibility.
566
567     TLS_CACERTFILE file name
568           The path to a certificate authority bundle which contains the cer‐
569           tificates for all the Certificate Authorities the client knows to
570           be valid, e.g. /etc/ssl/ca-bundle.pem.  This option is only sup‐
571           ported by the OpenLDAP libraries.  Netscape-derived LDAP libraries
572           use the same certificate database for CA and client certificates
573           (see TLS_CERT).
574
575     TLS_CACERTDIR directory
576           Similar to TLS_CACERTFILE but instead of a file, it is a directory
577           containing individual Certificate Authority certificates, e.g.
578           /etc/ssl/certs.  The directory specified by TLS_CACERTDIR is
579           checked after TLS_CACERTFILE.  This option is only supported by the
580           OpenLDAP libraries.
581
582     TLS_CERT file name
583           The path to a file containing the client certificate which can be
584           used to authenticate the client to the LDAP server.  The certifi‐
585           cate type depends on the LDAP libraries used.
586
587           OpenLDAP:
588                 tls_cert /etc/ssl/client_cert.pem
589
590           Netscape-derived:
591                 tls_cert /var/ldap/cert7.db
592
593           Tivoli Directory Server:
594                 Unused, the key database specified by TLS_KEY contains both
595                 keys and certificates.
596
597                 When using Netscape-derived libraries, this file may also
598                 contain Certificate Authority certificates.
599
600     TLS_CHECKPEER on/true/yes/off/false/no
601           If enabled, TLS_CHECKPEER will cause the LDAP server's TLS certifi‐
602           cated to be verified.  If the server's TLS certificate cannot be
603           verified (usually because it is signed by an unknown certificate
604           authority), sudo will be unable to connect to it.  If TLS_CHECKPEER
605           is disabled, no check is made.  Note that disabling the check cre‐
606           ates an opportunity for man-in-the-middle attacks since the
607           server's identity will not be authenticated.  If possible, the CA's
608           certificate should be installed locally so it can be verified.
609           This option is not supported by the Tivoli Directory Server LDAP
610           libraries.
611
612     TLS_KEY file name
613           The path to a file containing the private key which matches the
614           certificate specified by TLS_CERT.  The private key must not be
615           password-protected.  The key type depends on the LDAP libraries
616           used.
617
618           OpenLDAP:
619                 tls_key /etc/ssl/client_key.pem
620
621           Netscape-derived:
622                 tls_key /var/ldap/key3.db
623
624           Tivoli Directory Server:
625                 tls_key /usr/ldap/ldapkey.kdb
626           When using Tivoli LDAP libraries, this file may also contain Cer‐
627           tificate Authority and client certificates and may be encrypted.
628
629     TLS_CIPHERS cipher list
630           The TLS_CIPHERS parameter allows the administer to restrict which
631           encryption algorithms may be used for TLS (SSL) connections.  See
632           the OpenLDAP or Tivoli Directory Server manual for a list of valid
633           ciphers.  This option is not supported by Netscape-derived
634           libraries.
635
636     TLS_KEYPW secret
637           The TLS_KEYPW contains the password used to decrypt the key data‐
638           base on clients using the Tivoli Directory Server LDAP library.
639           The secret may be a plain text password or a base64-encoded string
640           with a “base64:” prefix.  For example:
641
642               TLS_KEYPW base64:dGVzdA==
643
644           If a plain text password is used, it should be a simple string
645           without quotes.  Plain text passwords may not include the comment
646           character (‘#’) and the escaping of special characters with a back‐
647           slash (‘\’) is not supported.  If this option is used,
648           /etc/sudo-ldap.conf must not be world-readable to avoid exposing
649           the password.  Alternately, a stash file can be used to store the
650           password in encrypted form (see below).
651
652           If no TLS_KEYPW is specified, a stash file will be used if it
653           exists.  The stash file must have the same path as the file speci‐
654           fied by TLS_KEY, but use a .sth file extension instead of .kdb,
655           e.g. ldapkey.sth.  The default ldapkey.kdb that ships with Tivoli
656           Directory Server is encrypted with the password ssl_password.  The
657           gsk8capicmd utility can be used to manage the key database and cre‐
658           ate a stash file.  This option is only supported by the Tivoli LDAP
659           libraries.
660
661     TLS_RANDFILE file name
662           The TLS_RANDFILE parameter specifies the path to an entropy source
663           for systems that lack a random device.  It is generally used in
664           conjunction with prngd or egd.  This option is only supported by
665           the OpenLDAP libraries.
666
667     URI ldap[s]://[hostname[:port]] ...
668           Specifies a white space-delimited list of one or more URIs describ‐
669           ing the LDAP server(s) to connect to.  The protocol may be either
670           ldap ldaps, the latter being for servers that support TLS (SSL)
671           encryption.  If no port is specified, the default is port 389 for
672           ldap:// or port 636 for ldaps://.  If no hostname is specified,
673           sudo will connect to localhost.  Multiple URI lines are treated
674           identically to a URI line containing multiple entries.  Only sys‐
675           tems using the OpenSSL libraries support the mixing of ldap:// and
676           ldaps:// URIs.  Both the Netscape-derived and Tivoli LDAP libraries
677           used on most commercial versions of Unix are only capable of sup‐
678           porting one or the other.
679
680     USE_SASL on/true/yes/off/false/no
681           Enable USE_SASL for LDAP servers that support SASL authentication.
682
683     ROOTSASL_AUTH_ID identity
684           The SASL user name to use when ROOTUSE_SASL is enabled.
685
686     See the ldap.conf entry in the EXAMPLES section.
687
688   Configuring nsswitch.conf
689     Unless it is disabled at build time, sudo consults the Name Service
690     Switch file, /etc/nsswitch.conf, to specify the sudoers search order.
691     Sudo looks for a line beginning with sudoers: and uses this to determine
692     the search order.  Note that sudo does not stop searching after the first
693     match and later matches take precedence over earlier ones.  The following
694     sources are recognized:
695
696         files     read sudoers from /etc/sudoers
697         ldap      read sudoers from LDAP
698
699     In addition, the entry [NOTFOUND=return] will short-circuit the search if
700     the user was not found in the preceding source.
701
702     To consult LDAP first followed by the local sudoers file (if it exists),
703     use:
704
705         sudoers: ldap files
706
707     The local sudoers file can be ignored completely by using:
708
709         sudoers: ldap
710
711     If the /etc/nsswitch.conf file is not present or there is no sudoers
712     line, the following default is assumed:
713
714         sudoers: files
715
716     Note that /etc/nsswitch.conf is supported even when the underlying oper‐
717     ating system does not use an nsswitch.conf file, except on AIX (see
718     below).
719
720   Configuring netsvc.conf
721     On AIX systems, the /etc/netsvc.conf file is consulted instead of
722     /etc/nsswitch.conf.  sudo simply treats netsvc.conf as a variant of
723     nsswitch.conf; information in the previous section unrelated to the file
724     format itself still applies.
725
726     To consult LDAP first followed by the local sudoers file (if it exists),
727     use:
728
729         sudoers = ldap, files
730
731     The local sudoers file can be ignored completely by using:
732
733         sudoers = ldap
734
735     To treat LDAP as authoritative and only use the local sudoers file if the
736     user is not present in LDAP, use:
737
738         sudoers = ldap = auth, files
739
740     Note that in the above example, the auth qualifier only affects user
741     lookups; both LDAP and sudoers will be queried for Defaults entries.
742
743     If the /etc/netsvc.conf file is not present or there is no sudoers line,
744     the following default is assumed:
745
746         sudoers = files
747
748   Integration with sssd
749     On systems with the System Security Services Daemon (SSSD) and where sudo
750     has been built with SSSD support, it is possible to use SSSD to cache
751     LDAP sudoers rules.  To use SSSD as the sudoers source, you should use
752     sssd instead of ldap for the sudoers entry in /etc/nsswitch.conf.  Note
753     that the /etc/sudo-ldap.conf file is not used by the SSSD sudo back end.
754     Please see sssd-sudo(5) for more information on configuring sudo to work
755     with SSSD.
756

FILES

758     /etc/sudo-ldap.conf       LDAP configuration file
759
760     /etc/nsswitch.conf        determines sudoers source order
761
762     /etc/netsvc.conf          determines sudoers source order on AIX
763

EXAMPLES

765   Example ldap.conf
766       # Either specify one or more URIs or one or more host:port pairs.
767       # If neither is specified sudo will default to localhost, port 389.
768       #
769       #host          ldapserver
770       #host          ldapserver1 ldapserver2:390
771       #
772       # Default port if host is specified without one, defaults to 389.
773       #port          389
774       #
775       # URI will override the host and port settings.
776       uri            ldap://ldapserver
777       #uri            ldaps://secureldapserver
778       #uri            ldaps://secureldapserver ldap://ldapserver
779       #
780       # The amount of time, in seconds, to wait while trying to connect to
781       # an LDAP server.
782       bind_timelimit 30
783       #
784       # The amount of time, in seconds, to wait while performing an LDAP query.
785       timelimit 30
786       #
787       # Must be set or sudo will ignore LDAP; may be specified multiple times.
788       sudoers_base   ou=SUDOers,dc=my-domain,dc=com
789       #
790       # verbose sudoers matching from ldap
791       #sudoers_debug 2
792       #
793       # Enable support for time-based entries in sudoers.
794       #sudoers_timed yes
795       #
796       # optional proxy credentials
797       #binddn        <who to search as>
798       #bindpw        <password>
799       #rootbinddn    <who to search as, uses /etc/ldap.secret for bindpw>
800       #
801       # LDAP protocol version, defaults to 3
802       #ldap_version 3
803       #
804       # Define if you want to use an encrypted LDAP connection.
805       # Typically, you must also set the port to 636 (ldaps).
806       #ssl on
807       #
808       # Define if you want to use port 389 and switch to
809       # encryption before the bind credentials are sent.
810       # Only supported by LDAP servers that support the start_tls
811       # extension such as OpenLDAP.
812       #ssl start_tls
813       #
814       # Additional TLS options follow that allow tweaking of the
815       # SSL/TLS connection.
816       #
817       #tls_checkpeer yes # verify server SSL certificate
818       #tls_checkpeer no  # ignore server SSL certificate
819       #
820       # If you enable tls_checkpeer, specify either tls_cacertfile
821       # or tls_cacertdir.  Only supported when using OpenLDAP.
822       #
823       #tls_cacertfile /etc/certs/trusted_signers.pem
824       #tls_cacertdir  /etc/certs
825       #
826       # For systems that don't have /dev/random
827       # use this along with PRNGD or EGD.pl to seed the
828       # random number pool to generate cryptographic session keys.
829       # Only supported when using OpenLDAP.
830       #
831       #tls_randfile /etc/egd-pool
832       #
833       # You may restrict which ciphers are used.  Consult your SSL
834       # documentation for which options go here.
835       # Only supported when using OpenLDAP.
836       #
837       #tls_ciphers <cipher-list>
838       #
839       # Sudo can provide a client certificate when communicating to
840       # the LDAP server.
841       # Tips:
842       #   * Enable both lines at the same time.
843       #   * Do not password protect the key file.
844       #   * Ensure the keyfile is only readable by root.
845       #
846       # For OpenLDAP:
847       #tls_cert /etc/certs/client_cert.pem
848       #tls_key  /etc/certs/client_key.pem
849       #
850       # For SunONE or iPlanet LDAP, tls_cert and tls_key may specify either
851       # a directory, in which case the files in the directory must have the
852       # default names (e.g. cert8.db and key4.db), or the path to the cert
853       # and key files themselves.  However, a bug in version 5.0 of the LDAP
854       # SDK will prevent specific file names from working.  For this reason
855       # it is suggested that tls_cert and tls_key be set to a directory,
856       # not a file name.
857       #
858       # The certificate database specified by tls_cert may contain CA certs
859       # and/or the client's cert.  If the client's cert is included, tls_key
860       # should be specified as well.
861       # For backward compatibility, "sslpath" may be used in place of tls_cert.
862       #tls_cert /var/ldap
863       #tls_key /var/ldap
864       #
865       # If using SASL authentication for LDAP (OpenSSL)
866       # use_sasl yes
867       # sasl_auth_id <SASL user name>
868       # rootuse_sasl yes
869       # rootsasl_auth_id <SASL user name for root access>
870       # sasl_secprops none
871       # krb5_ccname /etc/.ldapcache
872
873   Sudo schema for OpenLDAP
874     The following schema, in OpenLDAP format, is included with sudo source
875     and binary distributions as schema.OpenLDAP.  Simply copy it to the
876     schema directory (e.g. /etc/openldap/schema), add the proper include line
877     in slapd.conf and restart slapd.
878
879       attributetype ( 1.3.6.1.4.1.15953.9.1.1
880          NAME 'sudoUser'
881          DESC 'User(s) who may  run sudo'
882          EQUALITY caseExactIA5Match
883          SUBSTR caseExactIA5SubstringsMatch
884          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
885
886       attributetype ( 1.3.6.1.4.1.15953.9.1.2
887          NAME 'sudoHost'
888          DESC 'Host(s) who may run sudo'
889          EQUALITY caseExactIA5Match
890          SUBSTR caseExactIA5SubstringsMatch
891          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
892
893       attributetype ( 1.3.6.1.4.1.15953.9.1.3
894          NAME 'sudoCommand'
895          DESC 'Command(s) to be executed by sudo'
896          EQUALITY caseExactIA5Match
897          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
898
899       attributetype ( 1.3.6.1.4.1.15953.9.1.4
900          NAME 'sudoRunAs'
901          DESC 'User(s) impersonated by sudo'
902          EQUALITY caseExactIA5Match
903          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
904
905       attributetype ( 1.3.6.1.4.1.15953.9.1.5
906          NAME 'sudoOption'
907          DESC 'Options(s) followed by sudo'
908          EQUALITY caseExactIA5Match
909          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
910
911       attributetype ( 1.3.6.1.4.1.15953.9.1.6
912          NAME 'sudoRunAsUser'
913          DESC 'User(s) impersonated by sudo'
914          EQUALITY caseExactIA5Match
915          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
916
917       attributetype ( 1.3.6.1.4.1.15953.9.1.7
918          NAME 'sudoRunAsGroup'
919          DESC 'Group(s) impersonated by sudo'
920          EQUALITY caseExactIA5Match
921          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
922
923       attributetype ( 1.3.6.1.4.1.15953.9.1.8
924          NAME 'sudoNotBefore'
925          DESC 'Start of time interval for which the entry is valid'
926          EQUALITY generalizedTimeMatch
927          ORDERING generalizedTimeOrderingMatch
928          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
929
930       attributetype ( 1.3.6.1.4.1.15953.9.1.9
931          NAME 'sudoNotAfter'
932          DESC 'End of time interval for which the entry is valid'
933          EQUALITY generalizedTimeMatch
934          ORDERING generalizedTimeOrderingMatch
935          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
936
937       attributetype ( 1.3.6.1.4.1.15953.9.1.10
938           NAME 'sudoOrder'
939           DESC 'an integer to order the sudoRole entries'
940           EQUALITY integerMatch
941           ORDERING integerOrderingMatch
942           SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
943
944       objectclass ( 1.3.6.1.4.1.15953.9.2.1 NAME 'sudoRole' SUP top STRUCTURAL
945          DESC 'Sudoer Entries'
946          MUST ( cn )
947          MAY ( sudoUser $ sudoHost $ sudoCommand $ sudoRunAs $ sudoRunAsUser $
948                sudoRunAsGroup $ sudoOption $ sudoNotBefore $ sudoNotAfter $
949                sudoOrder $ description )
950          )
951

SEE ALSO

953     cvtsudoers(1), ldap.conf(5), sssd-sudo(5), sudo.conf(5), sudoers(5)
954

AUTHORS

956     Many people have worked on sudo over the years; this version consists of
957     code written primarily by:
958
959           Todd C. Miller
960
961     See the CONTRIBUTORS file in the sudo distribution
962     (https://www.sudo.ws/contributors.html) for an exhaustive list of people
963     who have contributed to sudo.
964

CAVEATS

966     Note that there are differences in the way that LDAP-based sudoers is
967     parsed compared to file-based sudoers.  See the Differences between LDAP
968     and non-LDAP sudoers section for more information.
969

BUGS

971     If you feel you have found a bug in sudo, please submit a bug report at
972     https://bugzilla.sudo.ws/
973

SUPPORT

975     Limited free support is available via the sudo-users mailing list, see
976     https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
977     the archives.
978

DISCLAIMER

980     sudo is provided “AS IS” and any express or implied warranties, includ‐
981     ing, but not limited to, the implied warranties of merchantability and
982     fitness for a particular purpose are disclaimed.  See the LICENSE file
983     distributed with sudo or https://www.sudo.ws/license.html for complete
984     details.
985
986Sudo 1.8.25p1                    June 25, 2018                   Sudo 1.8.25p1
Impressum