389 Directory Server TLS Client CentOS

389 Directory Server TLS Client CentOS

This blog is about joining a PC/server to 389 directory server as a client using TLS. For ease of use, we wrote a script, here it is!

Prerequisites

  • A 389 Directory Server with TLS/SSL already enabled (see Configure TLS/SSL 389 Directory Server CentOS).
  • A CentOS 6 client with the LDAP client packages: yum -y install openldap-clients nss-pam-ldapd pam_ldap.
  • The server host names and base DN of your directory.

The script

#!/bin/sh
# Created by Andrew Zwieg 10/22/2014
# Version 1.15
# Add/Upgrade LDAP authentication to TLS

# Update LDAP to Secure LDAP
echo “TLS_REQCERT allow” >> /etc/openldap/ldap.conf
echo “tls_reqcert allow” >> /etc/nslcd.conf
echo “tls_reqcert allow” >> /etc/pam_ldap.conf

# Configure LDAP configuration (Insecure)
authconfig –enableldaptls –enableldapauth –ldapserver=server1,server2 –ldapbasedn=”dc=domain,dc=local” –update
echo LDAP authentication configured…

The same script as plain text, with the double dashes the authconfig options need (the blog formatting turned them into single long dashes above):

#!/bin/sh
# Add/Upgrade LDAP authentication to TLS
echo "TLS_REQCERT allow" >> /etc/openldap/ldap.conf
echo "tls_reqcert allow" >> /etc/nslcd.conf
echo "tls_reqcert allow" >> /etc/pam_ldap.conf
authconfig --enableldaptls --enableldapauth --ldapserver=server1,server2 --ldapbasedn="dc=domain,dc=local" --update
echo LDAP authentication configured...

What each part does

  • The three echo lines append a relaxed certificate check to the OpenLDAP client library, nslcd and pam_ldap config files. allow means the client asks for the server certificate but carries on even if it cannot verify it, which is handy with self-signed certificates.
  • authconfig --enableldaptls turns on StartTLS (encryption on port 389), --enableldapauth uses LDAP for password checks, and --ldapserver/--ldapbasedn point at your servers and tree. --update writes the settings and restarts the needed services.

Run it

  1. touch scriptname.sh
  2. Insert above data (edit for your environment)
  3. chmod +x scriptname.sh
  4. ./scripname.sh

Because the script appends with >>, running it twice adds duplicate lines; check the files before running it again.

Verify

getent passwd ldapuser
id ldapuser
ldapsearch -x -ZZ -H ldap://server1 -b "dc=domain,dc=local" uid=ldapuser

getent and id prove that name lookups go to the directory, and -ZZ makes ldapsearch fail unless StartTLS succeeds. Finally log in over SSH as an LDAP user.

That’s it! You have successfully configured a TLS 389 Directory Server Client.

Troubleshooting

  • getent returns nothing: check service nslcd status and the server and base DN in /etc/nslcd.conf.
  • TLS errors: make sure the server really has TLS enabled and that port 389 is open.
  • Better security: TLS_REQCERT allow does not protect against a fake server. Copy your CA certificate to the client (for example into /etc/openldap/cacerts) and use demand once it is trusted.

RHEL, AlmaLinux and Rocky 8/9/10

authconfig and nslcd were replaced by authselect and SSSD. Install sssd sssd-ldap oddjob-mkhomedir, create /etc/sssd/sssd.conf (mode 600) with a domain using id_provider = ldap, auth_provider = ldap, ldap_uri = ldap://server1,ldap://server2, ldap_search_base = dc=domain,dc=local, ldap_id_use_start_tls = true and ldap_tls_cacert pointing at your CA file, then run authselect select sssd with-mkhomedir --force and systemctl enable --now sssd oddjobd.

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Configure TLS/SSL 389 Directory Server CentOS | Join CentOS to 389 Directory Server

3 Comments

Leave a Reply

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