{"id":5434,"date":"2020-04-13T16:51:44","date_gmt":"2020-04-13T13:51:44","guid":{"rendered":"https:\/\/kifarunix.com\/?p=5434"},"modified":"2021-09-17T22:17:18","modified_gmt":"2021-09-17T19:17:18","slug":"configure-openldap-sssd-client-on-centos-6-7","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-openldap-sssd-client-on-centos-6-7\/","title":{"rendered":"Configure OpenLDAP SSSD client on CentOS 6\/7"},"content":{"rendered":"\n
Do you have some old CentOS system, CentOS 7 or CentOS 6 and want to enable OpenLDAP authentication? Well, follow through this guide to learn how configure OpenLDAP SSSD<\/a> client on CentOS 6\/7. Well, as you might already know, SSSD offers quite a number of benefits including;<\/p>\n\n\n\n Well, you can’t be setting up SSSD client for OpenLDAP authentication without a running OpenLDAP server. Want to run OpenLDAP server on a CentOS 8 system? Follow the link below to setup one;<\/p>\n\n\n\n Install and Setup OpenLDAP on CentOS 8<\/a><\/p>\n\n\n\n Another thing to note is that, SSSD does not support authentication over an unencrypted channel<\/strong>.<\/p>\n\n\n\n To configure OpenLDAP server with SSL\/TLS support, you can update the OpenLDAP Server TLS certificates attributes as follows;<\/p>\n\n\n\n Replace the paths to the CA, Server Certificate and the key accordingly.<\/strong><\/p>\n\n\n\n You can the update OpenLDAP database as follows;<\/p>\n\n\n\n You can confirm this by running;<\/p>\n\n\n\n Change the location of the CA certificate on You should also install the same CA certificate on all of your client machines.<\/strong><\/p>\n\n\n\n The install SSSD and other SSSD userspace tools for manipulating users, groups, and nested groups, run the command below;<\/p>\n\n\n\n Once the installation completes, the next step is to configure SSSD for OpenLDAP authentication on CentOS 6\/CentOS 7.<\/p>\n\n\n\n By default, SSSD doesn’t create a configuration file. As such, you need to create it and define you authentication parameter options.<\/p>\n\n\n\n Setup you SSSD LDAP authentication parameters such that it may look like in below;<\/p>\n\n\n\n Set the appropriate the values, at least, for the following parameters;<\/p>\n\n\n\n Download the CA certificate of the OpenLDAP server by running the command below.<\/p>\n\n\n\n Copy the certificate and store it on the specified file by the value of the Also, on the Verify the CA certificate;<\/p>\n\n\n\n If the you get the, Verify return code: 0 (ok)<\/strong> status, then the certificate is fine.<\/p>\n\n\n\n Set the proper ownership and permissions on SSSD configuration file.<\/p>\n\n\n\n Update the NSS and PAM to use SSSD to manage authentication resources. This can be achieved using the Install the Load the Start and enable oddjobd to run on system boot.<\/p>\n\n\n\n On CentOS 7;<\/p>\n\n\n\n On CentOS 6;<\/p>\n\n\n\n Next, update the NSS and PAM configurations.<\/p>\n\n\n\n These command updates the The configuration is now done. Start and enable SSSD to run on system boot.<\/p>\n\n\n\n On CentOS 7<\/p>\n\n\n\n On CentOS 6;<\/p>\n\n\n\n Check the status.<\/p>\n\n\n\n In our OpenLDAP server, we have created a few user entries;<\/p>\n\n\n\n On either CentOS 7 or CentOS 6, depending on the LDAP filter used, you should now have users on the system. Use id command to verify this.<\/p>\n\n\n\n Verify auto-home directory creation.<\/p>\n\n\n\n You have successfully authenticated an OpenLDAP user via SSSD on both CentOS 7 and CentOS 6.<\/p>\n\n\n\n That brings us to the end of our guide on how to install and configure OpenLDAP SSSD client on CentOS 6\/7<\/p>\n\n\n\n Install and Setup FreeIPA Server on CentOS 8<\/a><\/p>\n\n\n\n Setup OpenLDAP Master-Slave Replication on CentOS 8<\/a><\/p>\n\n\n\nConfigure OpenLDAP SSSD client on CentOS 6\/7<\/h2>\n\n\n\n
Setup OpenLDAP Server with TLS\/SSL Support<\/h3>\n\n\n\n
vi enable-tls.ldif<\/code><\/pre>\n\n\n\n
\ndn: cn=config\nchangetype: modify\nadd: olcTLSCACertificateFile\nolcTLSCACertificateFile: \/etc\/pki\/tls\/cacert.pem\n-\nadd: olcTLSCertificateKeyFile\nolcTLSCertificateKeyFile: \/etc\/pki\/tls\/ldapserver.key\n-\nadd: olcTLSCertificateFile\nolcTLSCertificateFile: \/etc\/pki\/tls\/ldapserver.crt\n<\/code><\/pre>\n\n\n\n
ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f add-tls.ldif<\/code><\/pre>\n\n\n\n
slapcat -b \"cn=config\" | grep olcTLS<\/code><\/pre>\n\n\n\n
olcTLSCACertificateFile: \/etc\/pki\/tls\/cacert.pem\nolcTLSCertificateKeyFile: \/etc\/pki\/tls\/ldapserver.key\nolcTLSCertificateFile: \/etc\/pki\/tls\/ldapserver.crt<\/code><\/pre>\n\n\n\n
\/etc\/openldap\/ldap.conf<\/code>.<\/p>\n\n\n\n
vim \/etc\/openldap\/ldap.conf<\/code><\/pre>\n\n\n\n
...\n#TLS_CACERT \/etc\/pki\/tls\/cert.pem\nTLS_CACERT \/etc\/pki\/tls\/cacert.pem<\/strong><\/code><\/pre>\n\n\n\n
Install SSSD on CentOS 6\/CentOS 7<\/h3>\n\n\n\n
yum install sssd sssd-tools<\/code><\/pre>\n\n\n\n
Configure SSSD for OpenLDAP Authentication<\/h3>\n\n\n\n
vim \/etc\/sssd\/sssd.conf<\/code><\/pre>\n\n\n\n
\n[sssd]\nservices = nss, pam\nconfig_file_version = 2\ndomains = default\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\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\/openldap\/certs\/cacert.pem\nldap_search_timeout = 50\nldap_network_timeout = 60\nldap_access_order = filter\nldap_access_filter = (objectClass=posixAccount)\n<\/code><\/pre>\n\n\n\n
ldap_search_base<\/code><\/li>
ldap_uri<\/code><\/li>
ldap_default_bind_dn<\/code><\/li>
ldap_default_authtok<\/code><\/li>
ldap_tls_cacert<\/code><\/li>
ldap_access_filter<\/code><\/li><\/ul>\n\n\n\n
true | openssl s_client -connect ldapmaster.kifarunix-demo.com:636 2>\/dev\/null | openssl x509<\/code><\/pre>\n\n\n\n
ldap_tls_cacert<\/code> parameter,
\/etc\/openldap\/certs\/cacert.pem<\/strong><\/code>.<\/p>\n\n\n\n
vim \/etc\/openldap\/certs\/cacert.pem<\/code><\/pre>\n\n\n\n
\n-----BEGIN CERTIFICATE-----\nMIIDPDCCAiSgAwIBAgIULKGcNBKQU9LqklS27aLVr5NFgoQwDQYJKoZIhvcNAQEL\nBQAwHzEdMBsGA1UEAwwUKi5raWZhcnVuaXgtZGVtby5jb20wHhcNMjAwNDEzMTAx\n...\nsLwoxITLon23PB1Twc6heMFh1hkug3JXbtr5AJglU8JdGNtXM6e3ct+cAf2F\/hRR\nHGs85jrn634RNXMPWZ8lqChr1QLKlDsOz89tTQ4zvDBqQPweo8de2B\/ybTIUJu0o\nOUyCrLx8BK44vjEz0jvpOA==\n-----END CERTIFICATE-----\n<\/code><\/pre>\n\n\n\n
\/etc\/openldap\/ldap.conf<\/strong><\/code> configuration, specify the path to CA certificates as defined by the value of
ldap_tls_cacertdir<\/code> parameter.<\/p>\n\n\n\n
vim \/etc\/openldap\/ldap.conf<\/code><\/pre>\n\n\n\n
...\nTLS_CACERT \/etc\/openldap\/certs\/cacert.pem<\/strong><\/code><\/pre>\n\n\n\n
openssl s_client -connect ldapmaster.kifarunix-demo.com:636 -CAfile \/etc\/openldap\/certs\/cacert.pem<\/strong><\/code><\/pre>\n\n\n\n
chown -R root:root \/etc\/sssd\/\nchmod -R 600 \/etc\/sssd\/<\/code><\/pre>\n\n\n\n
Integrate NSS and PAM with SSSD on CentOS 7\/CentOS 6<\/h3>\n\n\n\n
authconfig<\/strong><\/code> utility<\/p>\n\n\n\n
Configure Automatic Home Directory Creation<\/h4>\n\n\n\n
oddjob-mkhomedir<\/strong><\/code>, which provides the
pam_oddjob_mkhomedir<\/strong><\/code> module to create a home directory for a user at login-time.<\/p>\n\n\n\n
yum install oddjob-mkhomedir<\/code><\/pre>\n\n\n\n
pam_oddjob_mkhomedir<\/strong><\/code> module in PAM auth file
\/etc\/pam.d\/system-auth<\/code> to enable auto home directory creation.<\/p>\n\n\n\n
echo \"session optional pam_oddjob_mkhomedir.so skel=\/etc\/skel\/ umask=0022\" >> \/etc\/pam.d\/system-auth<\/code><\/pre>\n\n\n\n
systemctl enable --now oddjobd<\/code><\/pre>\n\n\n\n
service messagebus start\nservice oddjobd start<\/code><\/pre>\n\n\n\n
chkconfig messagebus on\nchkconfig oddjobd on<\/code><\/pre>\n\n\n\n
authconfig --enablesssd --enablesssdauth --enablemkhomedir --update<\/code><\/pre>\n\n\n\n
\/etc\/nsswitch.conf<\/code> and
\/etc\/pam.d\/system-auth<\/code> and
\/etc\/pam.d\/password-auth<\/code> files with relevant PAM modules for SSSD.<\/p>\n\n\n\n
Running SSSD on CentOS 6\/CentOS 7<\/h3>\n\n\n\n
systemctl enable --now sssd<\/code><\/pre>\n\n\n\n
service sssd start\nchkconfig sssd on<\/code><\/pre>\n\n\n\n
systemctl status sssd<\/code><\/pre>\n\n\n\n
\n\u25cf sssd.service - System Security Services Daemon\n Loaded: loaded (\/usr\/lib\/systemd\/system\/sssd.service; enabled; vendor preset: disabled)\n Active: active (running) since Mon 2020-04-13 16:31:30 EAT; 3s ago\n Main PID: 10472 (sssd)\n CGroup: \/system.slice\/sssd.service\n \u251c\u250010472 \/usr\/sbin\/sssd -i --logger=files\n \u251c\u250010473 \/usr\/libexec\/sssd\/sssd_be --domain default --uid 0 --gid 0 --logger=files\n \u251c\u250010474 \/usr\/libexec\/sssd\/sssd_nss --uid 0 --gid 0 --logger=files\n \u2514\u250010475 \/usr\/libexec\/sssd\/sssd_pam --uid 0 --gid 0 --logger=files\n\nApr 13 16:31:30 centos7.kifarunix-demo.com systemd[1]: Stopped System Security Services Daemon.\nApr 13 16:31:30 centos7.kifarunix-demo.com systemd[1]: Starting System Security Services Daemon...\nApr 13 16:31:30 centos7.kifarunix-demo.com sssd[10472]: Starting up\nApr 13 16:31:30 centos7.kifarunix-demo.com sssd[be[default]][10473]: Starting up\nApr 13 16:31:30 centos7.kifarunix-demo.com sssd[nss][10474]: Starting up\nApr 13 16:31:30 centos7.kifarunix-demo.com sssd[pam][10475]: Starting up\nApr 13 16:31:30 centos7.kifarunix-demo.com systemd[1]: Started System Security Services Daemon.\n<\/code><\/pre>\n\n\n\n
service sssd status<\/strong><\/code><\/pre>\n\n\n\n
sssd (pid 2913) is running\u2026<\/code><\/pre>\n\n\n\n
Verify OpenLDAP Authentication via SSSD<\/h3>\n\n\n\n
ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -b \"ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\" uid -LLL -Q<\/code><\/pre>\n\n\n\n
dn: ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n\ndn: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nuid: janedoe\n\ndn: uid=johndoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nuid: johndoe<\/strong><\/code><\/pre>\n\n\n\n
[root@centos6 ~]# id janedoe<\/strong>\nuid=10010(janedoe) gid=10010(janedoe) groups=10010(janedoe)<\/strong><\/code><\/pre>\n\n\n\n
[root@centos7 ~]# id johndoe\nuid=10000(johndoe) gid=10000(johndoe) groups=10000(johndoe)<\/strong>\n[root@centos7 ~]#<\/code><\/pre>\n\n\n\n
[root@centos6 ~]# ssh -l janedoe localhost<\/strong>\njanedoe@localhost's password:\nCreating home directory for janedoe.<\/strong>\nLast login: Mon Apr 13 16:24:36 2020\n[janedoe@centos6 ~]$ pwd\n\/home\/janedoe<\/strong><\/code><\/pre>\n\n\n\n
[root@centos7 ~]# ssh -l johndoe localhost<\/strong>\njohndoe@localhost's password:\nCreating home directory for johndoe.<\/strong>\n[johndoe@centos7 ~]$ pwd\n\/home\/johndoe<\/code><\/pre>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n