Join CentOS to 389 Directory Server

For ease of password administration and management, sometimes it’s better to join to a conformed directory structure. In this case LDAP is what we are using — specifically a 389 Directory Server, with the CentOS client talking to it through nss-pam-ldapd and authconfig. This keeps the original authconfig-tui flow, then notes the modern authselect/sssd approach on AlmaLinux and RHEL 8+.

Prerequisites

  • A working 389 Directory Server with a Base DN (this example uses dc=domain,dc=com on 192.168.1.201).
  • Root on the CentOS client, and network access to the LDAP port (389 or 636).
  • The LDAP server’s CA certificate if you will turn on TLS (optional in this walkthrough; Use TLS was left unchecked).

1. Become root on the CentOS client

Login to your CentOS Client, and su to root.

Root shell on the CentOS client LDAP1 before installing the 389 Directory Server client packages

2. Install the LDAP client packages

Install the necessary tools. The package that provides the nss/PAM LDAP daemon used here is nss-pam-ldapd:

yum install nss-pam-ldapd
Running yum install nss-pam-ldapd on CentOS client LDAP1 for LDAP name service support

On many CentOS 6 systems you also want authconfig / authconfig-gtk for the TUI, and openldap-clients for ldapsearch tests. Install those if they are missing.

3. Launch authconfig-tui

Launch authconfig-tui:

authconfig-tui
Launching authconfig-tui on CentOS to open the Authentication Configuration screen

4. Enable LDAP user information and authentication

Configure as shown below: under User Information select Use LDAP; under Authentication select Use Shadow Passwords, Use LDAP Authentication, and Local authorization is sufficient, then choose Next.

Authentication Configuration TUI with Use LDAP, Shadow Passwords and LDAP Authentication selected

5. Set the LDAP server and Base DN

Customize for your environment. In LDAP Settings set the Server URI and Base DN — here ldap://192.168.1.201/ and dc=domain,dc=com. Leave Use TLS unchecked unless you have already distributed a CA certificate to the client.

LDAP Settings TUI with Server ldap://192.168.1.201/ and Base DN dc=domain,dc=com
authconfig-tui finished and returning to the root shell on CentOS client LDAP1

Started! authconfig writes /etc/nslcd.conf, /etc/pam.d/* and the NSS LDAP settings, and starts nslcd.

6. Create home directories automatically

Tell this box to automatically create home directories when an LDAP user logs in for the first time:

authconfig --enablemkhomedir --update
Running authconfig --enablemkhomedir --update on LDAP1 with nslcd starting OK

You should see nslcd start with [ OK ]. That’s it!

Verify

getent passwd some_ldap_user
id some_ldap_user
ldapsearch -x -H ldap://192.168.1.201/ -b dc=domain,dc=com '(uid=some_ldap_user)'

getent and id should resolve the LDAP user. Then SSH in as that user and confirm a home directory appears under /home.

Troubleshooting

  • getent shows nothing: nslcd is not running, or the Base DN/URI is wrong. Check service nslcd status and the URI in /etc/nslcd.conf.
  • Login fails but getent works: PAM LDAP authentication is off, or the user password is not in the directory. Re-run authconfig-tui and confirm Use LDAP Authentication.
  • TLS errors: if you enable Use TLS, install the CA under /etc/openldap/cacerts and run cacertdir_rehash /etc/openldap/cacerts (or point tls_cacertfile in nslcd.conf). See 389 Directory Server TLS Client CentOS.

AlmaLinux, Rocky Linux and RHEL 8–10

authconfig-tui is removed. Use authselect with SSSD (recommended) or install nss-pam-ldapd and configure /etc/nslcd.conf by hand:

dnf install sssd authselect oddjob-mkhomedir
authselect select sssd with-mkhomedir --force
# then edit /etc/sssd/sssd.conf for your ldap_uri and ldap_search_base
systemctl enable --now sssd oddjobd

authconfig --enablemkhomedir is replaced by the with-mkhomedir authselect feature plus oddjobd.

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Install 389 Directory Server CentOS | 389 Directory Server TLS Client CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *