{"id":4922,"date":"2020-01-17T17:45:05","date_gmt":"2020-01-17T14:45:05","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4922"},"modified":"2024-03-14T19:18:10","modified_gmt":"2024-03-14T16:18:10","slug":"configure-sssd-for-openldap-authentication-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-sssd-for-openldap-authentication-on-ubuntu-18-04\/","title":{"rendered":"Configure SSSD for OpenLDAP Authentication on Ubuntu 18.04"},"content":{"rendered":"\n<p>In this guide, we are going to learn how to configure SSSD for OpenLDAP Authentication on Ubuntu 18.04. <a rel=\"noreferrer noopener\" aria-label=\"SSSD (opens in a new tab)\" href=\"https:\/\/docs.pagure.org\/SSSD.sssd\/\" target=\"_blank\">SSSD<\/a> is an acronym for System Security Services Daemon. It &nbsp;provide access to local or remote identity and authentication resources through a common framework that can provide caching and offline support to the system. It also provides several interfaces, including NSS and PAM modules or a D-Bus interface.<\/p>\n\n\n\n<p>Before you can proceed, ensure that your got a running OpenLDAP server. You can follow the link below to learn how to setup OpenLDAP server on CentOS 8.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-openldap-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install and Setup OpenLDAP on CentOS 8<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring SSSD for OpenLDAP Authentication<\/h2>\n\n\n\n<p>In this demo, we are going to setup SSSD on Ubuntu 18.04 desktop.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update your System<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install SSSD and Required Packages<\/h3>\n\n\n\n<p>Run the command below to install SSSD onUbuntu 18.04 and other required packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install sssd libpam-sss libnss-sss<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure SSSD&nbsp;on Ubuntu 18.04<\/h3>\n\n\n\n<p>Once the installation is done, proceed to configure SSSD for OpenLDAP authentication.<\/p>\n\n\n\n<p>Create SSSD configuration file (Not created by default) with the following content;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/sssd\/sssd.conf<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>[sssd]\nservices = nss, pam\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\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\/ssl\/certs\/cacert.crt\nldap_tls_cacertdir = \/etc\/ssl\/certs\nldap_search_timeout = 50\nldap_network_timeout = 60\nldap_access_order = filter\nldap_access_filter = (objectClass=posixAccount)\n<\/code><\/pre>\n\n\n\n<p>Replace the values of the highlighted lines above according to your OpenLDAP setup.<\/p>\n\n\n\n<p>Read more about the configuration options on <strong><code>man sssd.conf<\/code><\/strong>.<\/p>\n\n\n\n<p>Save the file and exit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install OpenLDAP Server CA Certificate<\/h3>\n\n\n\n<p>To perform authentication, SSSD requires that the communication channel be encrypted. This means that the LDAP server must be configured to run in SSL or TLS with a valid certificate trust.<\/p>\n\n\n\n<p>Install the LDAP server CA certificate, under the file defined by the directive, <code><strong>ldap_tls_cacert<\/strong><\/code>, <strong><code>\/etc\/ssl\/certs\/cacert.crt<\/code><\/strong>.<\/p>\n\n\n\n<p>To download the CA certificate from the LDAP server, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openssl s_client -connect ldapmaster.kifarunix-demo.com:636 -showcerts &lt; \/dev\/null | openssl x509 -text | sed -ne '\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p'<\/code><\/pre>\n\n\n\n<p>Copy the certificate part;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-----BEGIN CERTIFICATE-----\nMIIDzzCCAregAwIBAgIUMJkYu\/S+fQbyGjUOLsMoar6owfowDQYJKoZIhvcNAQEL\nBQAwdzELMAkGA1UEBhMCS0UxDDAKBgNVBAgMA05haTEMMAoGA1UEBwwDTmFpMRcw\n...\n...\nJ4VrJYImrnvTNiDGcrXVQhKY2amBPb6g1Mwp5DiHPplvOF63F+Uzx9NFG1DhHMTq\nkqkfQw96SLItvsAXpeosfYkH6uEG36svqAJ6rzxZcJzl3OTrUZnFX3OOsmFeHupC\nQxv7gjfE5jqdD6iQR0cohGLpaA==\n-----END CERTIFICATE-----<\/code><\/pre>\n\n\n\n<p>Paste in the file, <strong><code>\/etc\/ssl\/certs\/cacert.crt<\/code><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/ssl\/certs\/cacert.crt<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>-----BEGIN CERTIFICATE-----\nMIIDzzCCAregAwIBAgIUMJkYu\/S+fQbyGjUOLsMoar6owfowDQYJKoZIhvcNAQEL\nBQAwdzELMAkGA1UEBhMCS0UxDDAKBgNVBAgMA05haTEMMAoGA1UEBwwDTmFpMRcw\n...\n...\nJ4VrJYImrnvTNiDGcrXVQhKY2amBPb6g1Mwp5DiHPplvOF63F+Uzx9NFG1DhHMTq\nkqkfQw96SLItvsAXpeosfYkH6uEG36svqAJ6rzxZcJzl3OTrUZnFX3OOsmFeHupC\nQxv7gjfE5jqdD6iQR0cohGLpaA==\n-----END CERTIFICATE-----<\/code><\/pre>\n\n\n\n<p>Next, open the <code><strong>\/etc\/ldap\/ldap.conf<\/strong><\/code> and replace the value of <strong><code>TLS_CACERT<\/code><\/strong> with the path to the above certificate.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/ldap\/ldap.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>...\n# TLS certificates (needed for GnuTLS)\n#TLS_CACERT     \/etc\/ssl\/certs\/ca-certificates.crt\n<strong>TLS_CACERT      \/etc\/ssl\/certs\/cacert.crt<\/strong><\/code><\/pre>\n\n\n\n<p>Save and close the configuration file.<\/p>\n\n\n\n<p>After that, assign the root user read\/write access to&nbsp;<code>\/etc\/sssd\/<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod 600 -R \/etc\/sssd<\/code><\/pre>\n\n\n\n<p>Restart SSSD service<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart sssd<\/code><\/pre>\n\n\n\n<p>Check the status of SSSD to ensure that it is running.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status sssd<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf sssd.service - System Security Services Daemon\n   Loaded: loaded (\/lib\/systemd\/system\/sssd.service; enabled; vendor preset: enabled)\n   Active: active (running) since Fri 2020-01-17 14:27:51 EAT; 6s ago\n Main PID: 3033 (sssd)\n    Tasks: 4 (limit: 2315)\n   CGroup: \/system.slice\/sssd.service\n           \u251c\u25003033 \/usr\/sbin\/sssd -i --logger=files\n           \u251c\u25003034 \/usr\/lib\/x86_64-linux-gnu\/sssd\/sssd_be --domain default --uid 0 --gid 0 --logger=files\n           \u251c\u25003035 \/usr\/lib\/x86_64-linux-gnu\/sssd\/sssd_nss --uid 0 --gid 0 --logger=files\n           \u2514\u25003036 \/usr\/lib\/x86_64-linux-gnu\/sssd\/sssd_pam --uid 0 --gid 0 --logger=files\n\nJan 17 14:27:50 amos systemd[1]: Starting System Security Services Daemon...\nJan 17 14:27:51 amos sssd[3033]: Starting up\nJan 17 14:27:51 amos sssd[be[3034]: Starting up\nJan 17 14:27:51 amos sssd[3036]: Starting up\nJan 17 14:27:51 amos sssd[3035]: Starting up\nJan 17 14:27:51 amos systemd[1]: Started System Security Services Daemon.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Auto-Home Directory Creation<\/h3>\n\n\n\n<p>To ensure that a user&#8217;s home directory is automatically created on first login, you need to configure the PAM modules (<code>pam_mkhomedir.so<\/code>) as shown below.<\/p>\n\n\n\n<p>Open the&nbsp;<code>\/etc\/pam.d\/common-session<\/code>&nbsp;configuration file and edit is ad follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/pam.d\/common-session<\/code><\/pre>\n\n\n\n<p>Add the line below just below the line,&nbsp;<code>session optional pam_sss.so<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>session required        pam_mkhomedir.so skel=\/etc\/skel\/ umask=0022<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>...\n# The pam_umask module will set the umask according to the system default in\n# \/etc\/login.defs and user settings, solving the problem of different\n# umask settings with different shells, display managers, remote sessions etc.\n# See \"man pam_umask\".\nsession optional                        pam_umask.so\n# and here are more per-package modules (the \"Additional\" block)\nsession required        pam_unix.so\nsession optional                        pam_sss.so\n<strong>session required        pam_mkhomedir.so skel=\/etc\/skel\/ umask=0022<\/strong>\nsession optional        pam_systemd.so\n# end of pam-auth-update config\n...\n<\/code><\/pre>\n\n\n\n<p>Save and exit the configuration file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Verify OpenLDAP authentication via SSH<\/h3>\n\n\n\n<p>You can now verify if you can login as an LDAP user to your Ubuntu 18.04 system via SSH.<\/p>\n\n\n\n<p>Note that the users used here are already added to our OpenLDAP server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ssh johndoe@192.168.56.159<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>johndoe@192.168.56.159's password: \nCreating directory '\/home\/johndoe'.\nWelcome to Ubuntu 18.04.2 LTS (GNU\/Linux 4.18.0-15-generic x86_64)\n\n * Documentation:  https:\/\/help.ubuntu.com\n * Management:     https:\/\/landscape.canonical.com\n * Support:        https:\/\/ubuntu.com\/advantage\n\n\n450 packages can be updated.\n223 updates are security updates.\n\nYour Hardware Enablement Stack (HWE) is supported until April 2023.\n\nThe programs included with the Ubuntu system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in \/usr\/share\/doc\/*\/copyright.\n\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\napplicable law.\n\njohndoe@amos:~$ pwd\n\/home\/johndoe\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Verify OpenLDAP authentication via GUI<\/h3>\n\n\n\n<p>In this demo, we are using the default Ubuntu 18.04 GDM display manager.<\/p>\n\n\n\n<p>On the login interface, click Not listed to enter your OpenLDAP username and password.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"379\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/gdm_ldap_login.png\" alt=\"Configure SSSD for OpenLDAP Authentication on Ubuntu 18.04\" class=\"wp-image-10446\" title=\"\"><\/figure><\/div>\n\n\n<p>Upon successful login, your home directory will be auto-created and boom, you land on your desktop.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1347\" height=\"680\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/ldapuser_profile.png\" alt=\"\" class=\"wp-image-10447\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/ldapuser_profile.png?v=1631905932 1347w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/09\/ldapuser_profile-768x388.png?v=1631905932 768w\" sizes=\"(max-width: 1347px) 100vw, 1347px\" \/><\/figure>\n\n\n\n<p>You can check our other tutorials on OpenLDAP by following the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-phpldapadmin-on-centos-8\/\" target=\"_blank\">Install phpLDAPadmin on CentOS 8<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-owncloud-openldap-authentication\/\" target=\"_blank\">Configure ownCloud OpenLDAP Authentication<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-openldap-host-based-authentication\/\" target=\"_blank\">Configure OpenLDAP Host Based Authentication<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-create-openldap-member-groups\/\" target=\"_blank\">How to Create OpenLDAP Member Groups<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn how to configure SSSD for OpenLDAP Authentication on Ubuntu 18.04. SSSD is an acronym for System Security<\/p>\n","protected":false},"author":1,"featured_media":10441,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,285,1099],"tags":[4100,1131,1270,1271,1269],"class_list":["post-4922","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-directory-server","category-openldap","tag-install-sssd-on-ubuntu-18-04-2","tag-sssd","tag-sssd-openldap","tag-sssd-openldap-authentication","tag-sssd-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4922"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=4922"}],"version-history":[{"count":7,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4922\/revisions"}],"predecessor-version":[{"id":21322,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4922\/revisions\/21322"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10441"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}