{"id":4771,"date":"2019-11-15T23:19:19","date_gmt":"2019-11-15T20:19:19","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4771"},"modified":"2024-03-12T23:13:43","modified_gmt":"2024-03-12T20:13:43","slug":"configure-sssd-for-openldap-authentication-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-sssd-for-openldap-authentication-on-centos-8\/","title":{"rendered":"Configure SSSD for OpenLDAP Authentication on CentOS 8"},"content":{"rendered":"\n

In this guide, we are going to demonstrate how to configure SSSD for OpenLDAP Authentication on CentOS 8. In our previous guides, we have covered how to install and setup OpenLDAP on CentOS 8 as well how to configure SUDO via OpenLDAP. See the links below;<\/p>\n\n\n\n

Install and Setup OpenLDAP on CentOS 8<\/a><\/p>\n\n\n\n

How to Configure SUDO via OpenLDAP Server<\/a><\/p>\n\n\n\n

Configuring SSSD for OpenLDAP Authentication on CentOS 8<\/h2>\n\n\n\n

SSSD<\/a> is an acronym for System Security Services Daemon. It provides access to different identity and authentication providers.<\/p>\n\n\n\n

In this demo, we are using OpenLDAP as our directory as well identity management server.<\/p>\n\n\n\n

Run system update<\/h3>\n\n\n\n

To update your system packages, execute the command below;<\/p>\n\n\n\n

dnf update<\/code><\/pre>\n\n\n\n

Install SSSD on CentOS 8<\/h3>\n\n\n\n

Once the system update is done, proceed to install SSSD and other SSSD tools.<\/p>\n\n\n\n

dnf install sssd sssd-tools<\/code><\/pre>\n\n\n\n

Configuring SSSD for OpenLDAP Authentication on CentOS 8<\/h3>\n\n\n\n

Next, configure SSSD to allow authentication to your local system via OpenLDAP.<\/p>\n\n\n\n

SSSD doesn’t usually ship with any default configuration file. As such you need to create and configure it manually.<\/p>\n\n\n\n

vim \/etc\/sssd\/sssd.conf<\/code><\/pre>\n\n\n\n

Paste the content below into sssd.conf<\/strong> file. Be sure to make the relevant substitutions replacing your domain components appropriately.<\/p>\n\n\n\n

\n[sssd]\nservices = nss, pam, sudo\nconfig_file_version = 2\ndomains = default\n\n[sudo]\n\n[nss]\n\n[pam]\noffline_credentials_expiration = 60\n\n[domain\/default]\nldap_id_use_start_tls = True\ncache_credentials = True\nldap_search_base = dc=ldapmaster,dc=kifarunix-demo,dc=com\nid_provider = ldap\nauth_provider = ldap\nchpass_provider = ldap\naccess_provider = ldap\nsudo_provider = ldap\nldap_uri = ldap:\/\/ldapmaster.kifarunix-demo.com\nldap_default_bind_dn = cn=readonly,ou=system,dc=ldapmaster,dc=kifarunix-demo,dc=com\nldap_default_authtok = P@ssWOrd\nldap_tls_reqcert = demand\nldap_tls_cacert = \/etc\/pki\/tls\/cacert.crt\nldap_tls_cacertdir = \/etc\/pki\/tls\nldap_search_timeout = 50\nldap_network_timeout = 60\nldap_sudo_search_base = ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\nldap_access_order = filter\nldap_access_filter = (objectClass=posixAccount)\n<\/code><\/pre>\n\n\n\n

Save and quit the configuration files. Be sure to make relevant changes accordingly.<\/p>\n\n\n\n

Note that we have also configured our OpenLDAP server to provide sudo rights as shown by the configurations;<\/p>\n\n\n\n

\nservices = nss, pam, sudo<\/strong>\n...\n\n[sudo]<\/strong>\n...\n\nldap_sudo_search_base = ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/strong>\n<\/code><\/pre>\n\n\n\n

If you are not using OpenLDAP for sudo rules<\/strong>, you can remove these configurations.<\/p>\n\n\n\n

Next, download the OpenLDAP server CA certificate and store it on the file specified by the ldap_tls_cacert<\/code> directive on the sssd.conf file above.<\/p>\n\n\n\n

openssl s_client -connect ldapmaster.kifarunix-demo.com:636 -showcerts < \/dev\/null | openssl x509 -text<\/code><\/pre>\n\n\n\n

Copy the certificate and paste it on the \/etc\/pki\/tls\/cacert.crt<\/code><\/strong>.<\/p>\n\n\n\n

vim \/etc\/pki\/tls\/cacert.crt<\/code><\/pre>\n\n\n\n
-----BEGIN CERTIFICATE-----\nMIIFxzCCA6+gAwIBAgIUV+l4aOvMCLlNQRKOpt9YfxcxA8MwDQYJKoZIhvcNAQEL\nBQAwczELMAkGA1UEBhMCS0UxEDAOBgNVBAgMB05haXJvYmkxDDAKBgNVBAcMA05h\n...\n...\n5deiMlJkrYv7wZ0prq0QO5lduGBuD9UJvRa8LBV0GEAiHZL5PJOnREHObbAH907E\neixIJpkcC4wguMaXDNqIv6WGdQtRUyIP8tdByXYJGrbRW0K\/K9qEaIZhJiAES1Qy\n8U96RdYBpLvDctRch1kIfvnAVffTxmObAGI9n64O89p48kocJwNI\/XQNRg==\n-----END CERTIFICATE-----<\/code><\/pre>\n\n\n\n

Next, open the \/etc\/openldap\/ldap.conf<\/code> configuration file and configure it as follows;<\/p>\n\n\n\n

vim \/etc\/openldap\/ldap.conf<\/code><\/pre>\n\n\n\n

Basically, you need to define the location of the CA certificate, the OpenLDAP search base, the URI and if you are providing SUDO via OpenLDAP, the SUDOers base.<\/p>\n\n\n\n

BASE    dc=ldapmaster,dc=kifarunix-demo,dc=com\nURI     ldaps:\/\/ldapmaster.kifarunix-demo.com:636\nSUDOERS_BASE    ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\n...\n...\nTLS_CACERT      \/etc\/pki\/tls\/cacert.crt\n...<\/code><\/pre>\n\n\n\n

Save and quit the configuration file.<\/p>\n\n\n\n

Configure Name Service Switch and PAM on CentOS 8<\/h3>\n\n\n\n

Next, you need to update the NSS and PAM to use SSSD to manage authentication resources.<\/p>\n\n\n\n

In previous versions of CentOS, you would use tools like authconfig<\/strong><\/code> but this has since been replaced by tools like authselect<\/strong><\/code>.<\/p>\n\n\n\n

Authselect<\/code> is a utility that simplifies the configuration of user authentication especially while using SSSD for authentication.<\/p>\n\n\n\n

Configure SSSD Profile<\/h4>\n\n\n\n

Authselect command when used to create an SSSD profile, will basically modify these files;<\/p>\n\n\n\n