{"id":6830,"date":"2020-08-27T22:35:12","date_gmt":"2020-08-27T19:35:12","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6830"},"modified":"2024-03-14T22:26:19","modified_gmt":"2024-03-14T19:26:19","slug":"install-and-configure-sssd-for-openldap-authentication-on-fedora-32-31-30","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-sssd-for-openldap-authentication-on-fedora-32-31-30\/","title":{"rendered":"Install and Configure SSSD for OpenLDAP Authentication on Fedora 32\/31\/30"},"content":{"rendered":"\n
In tutorial, you will learn how to install and configure SSSD for OpenLDAP Authentication on Fedora 32\/31\/30. SSSD<\/a> is an acronym for System Security Services Daemon (SSSD). “The primary function of SSSD is to 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 provides several interfaces, including NSS and PAM modules or a D-Bus interface”<\/em>.<\/p>\n\n\n\n Benefits of using SSSD for remote identity and authentication include;<\/p>\n\n\n\n As we continue with this guide, we assume that you already have an OpenLDAP server up and running. If you, follow the link below to install and configure OpenLDAP server on CentOS 8.<\/p>\n\n\n\n Install and Setup OpenLDAP on CentOS 8<\/a><\/p>\n\n\n\n Before you can proceed, ensure that your system packages are up-to-date.<\/p>\n\n\n\n Run the command below to install SSSD and other SSSD tools on Fedora 32\/31\/30. (this might already be installed by default).<\/p>\n\n\n\n Once the install of SSSD and its tools is done, proceed to configure it for your OpenLDAP authentication.<\/p>\n\n\n\n Note that, by default, SSSD does not ship with a configuration file. As such, you need to create an SSSD configuration ( Below is our sample SSSD configuration details. Be sure to make the relevant changes in the configurations below to reflect your OpenLDAP environment setup.<\/p>\n\n\n\n If you are providing SUDO rights via OpenLDAP, your SSSD should include the SUDO services and the SUDOERS search base, The SSSD configuration file would then look like;<\/p>\n\n\n\n For a detailed of all the options\/parameters used in the SSSD configuration, please refer to, Follow the link below to learn how to configure OpenLDAP to provide SUDO rights to authenticating clients.<\/p>\n\n\n\n How to Configure SUDO via OpenLDAP Server<\/a><\/p>\n\n\n\n SSSD requires that the communication channel be encrypted. As such, OpenLDAP has to be configured with SSL (uri uses If you OpenLDAP is configured with SSL (LDAP is listening on port 636<\/strong>), run the command below to download the CA certificate;<\/p>\n\n\n\n If you OpenLDAP is configured with TLS (LDAP is listening on port 389<\/strong>), run the command below to download the CA certificate;<\/p>\n\n\n\n The certificate is displayed on the standard output.<\/p>\n\n\n\n You need to copy this certificate and install in the file specified by the line, Paste the certificate in here;<\/p>\n\n\n\n Save and exit the file.<\/p>\n\n\n\n Update the NSS and PAM to use SSSD to manage authentication resources. Authselect command when used to create an SSSD profile, modify the files below;<\/p>\n\n\n\n Therefore, make a backup of these files just in case things don\u2019t work out.<\/p>\n\n\n\n Create an SSSD profile. This command will overwrite the nsswitch maps.<\/p>\n\n\n\n Next, if you have configured SUDO via OpenLDAP, the system to fetch sudo rights from SSSD\/OpenLDAP, hence edit the You can simply echo the line into the configuration file as shown below;<\/p>\n\n\n\n To enable automatic home directory creation for user upon first login, you need to install the Start and enable oddjobd to run on system boot.<\/p>\n\n\n\n Load the Restart oddjobd.<\/p>\n\n\n\n Before you can start SSSD, you need to check configuration for any typos or permissions;<\/p>\n\n\n\n As per the check output, set the read\/write access to The configuration is now done. Start and enable SSSD to run on system boot.<\/p>\n\n\n\n Check the status.<\/p>\n\n\n\n The installation and configuration of SSSD for OpenLDAP authentication on Fedora 32\/31\/30 is done. It is now time to verify the system authentication via OpenLDAP.<\/p>\n\n\n\n First, confirm that you can see your LDAP username on your system using Once the confirmation is done, you can verify the login. You can use SSH or GUI login on desktops systems.<\/p>\n\n\n\n How to Create OpenLDAP Member Groups<\/a><\/p>\n\n\n\n Configure SSSD for OpenLDAP Client Authentication on Debian 10\/9<\/a><\/p>\n\n\n\n Setup OpenLDAP Server with SSL\/TLS on Debian 10<\/a><\/p>\n\n\n\n Install and Configure OpenLDAP server on Fedora 29<\/a><\/p>\n\n\n\n Configure OpenLDAP Client on Debian 9 Stretch<\/a><\/p>\n\n\n\n\n
Install SSSD for OpenLDAP Authentication on Fedora<\/a><\/h2>\n\n\n\n
Run System Update<\/a><\/h3>\n\n\n\n
dnf update<\/code><\/pre>\n\n\n\n
Install SSSD on Fedora 32\/31\/30<\/a><\/h3>\n\n\n\n
dnf install sssd sssd-tools<\/code><\/pre>\n\n\n\n
Configure SSSD for OpenLDAP Authentication<\/a><\/h3>\n\n\n\n
sssd.conf,<\/strong><\/code> by default) file under the configuration directory,
\/etc\/sssd<\/strong><\/code> to define your OpenLDAP authentication settings.<\/p>\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\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_access_order = filter\nldap_access_filter = (objectClass=posixAccount)\n<\/code><\/pre>\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
man sssd.conf<\/strong><\/code>.<\/p>\n\n\n\n
Install OpenLDAP CA Certificate on Fedora 32\/31\/30<\/h3>\n\n\n\n
ldaps:\/\/<\/strong><\/code>) or TLS (uri used
ldap:\/\/<\/strong><\/code>).<\/p>\n\n\n\n
openssl s_client -connect ldapmaster.kifarunix-demo.com:636 -showcerts < \/dev\/null | openssl x509 -text | sed -ne '\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p'<\/code><\/pre>\n\n\n\n
openssl s_client -connect ldapmaster.kifarunix-demo.com:389 -starttls ldap -showcerts < \/dev\/null | openssl x509 -text | sed -ne '\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p'<\/code><\/pre>\n\n\n\n
\n-----BEGIN CERTIFICATE-----\nMIIDvzCCAqegAwIBAgIUc8imlOVhEej453dXtvacn7krg1MwDQYJKoZIhvcNAQEL\nBQAwbzELMAkGA1UEBhMCS0UxDDAKBgNVBAgMA05haTEMMAoGA1UEBwwDTWFpMRww\n...\n...\nUy7ivNi2PL6mBwxMpyi0zTopqTXSvi54APm48dd0JPsGLTIgPMc1WvaN7TsUeIBs\nIgf9K1e9M0Q+j2XEsTeCYVU\/v0Jt0kER0+V\/NM0IrDOX+6kRz6DNsZrwcMEf5Yvp\nARWZ\n-----END CERTIFICATE-----\n<\/code><\/pre>\n\n\n\n
ldap_tls_cacert = \/etc\/pki\/tls\/cacert.crt<\/strong><\/code>.<\/p>\n\n\n\n
vim \/etc\/pki\/tls\/cacert.crt<\/code><\/pre>\n\n\n\n
\n-----BEGIN CERTIFICATE-----\nMIIDvzCCAqegAwIBAgIUc8imlOVhEej453dXtvacn7krg1MwDQYJKoZIhvcNAQEL\nBQAwbzELMAkGA1UEBhMCS0UxDDAKBgNVBAgMA05haTEMMAoGA1UEBwwDTWFpMRww\n...\n...\nUy7ivNi2PL6mBwxMpyi0zTopqTXSvi54APm48dd0JPsGLTIgPMc1WvaN7TsUeIBs\nIgf9K1e9M0Q+j2XEsTeCYVU\/v0Jt0kER0+V\/NM0IrDOX+6kRz6DNsZrwcMEf5Yvp\nARWZ\n-----END CERTIFICATE-----\n<\/code><\/pre>\n\n\n\n
Configure NSS and PAM for SSSD Authentication on Fedora 32\/31\/30<\/a><\/h3>\n\n\n\n
Authselect<\/strong><\/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 on Fedora 32\/31\/30<\/h4>\n\n\n\n
\n
cp -r \/etc\/pam.d{,.original}\ncp \/etc\/nsswitch.conf{,.original}<\/code><\/pre>\n\n\n\n
authselect select sssd<\/code><\/pre>\n\n\n\n
\/etc\/nsswitch.conf<\/code> to include the line below.<\/p>\n\n\n\n
sudoers: files sss<\/code><\/pre>\n\n\n\n
echo \"sudoers: files sss\" >> \/etc\/nsswitch.conf<\/code><\/pre>\n\n\n\n
Configure Automatic Home Directory Creation At Login<\/a><\/h3>\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
dnf install oddjob-mkhomedir<\/code><\/pre>\n\n\n\n
systemctl enable --now oddjobd<\/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 restart oddjobd<\/code><\/pre>\n\n\n\n
Running SSSD on Fedora 32\/31\/30<\/a><\/h3>\n\n\n\n
sssctl config-check<\/code><\/pre>\n\n\n\n
File ownership and permissions check failed. Expected root:root and 0600.<\/strong><\/code><\/pre>\n\n\n\n
\/etc\/sssd\/<\/code> for the owner (root).<\/p>\n\n\n\n
chown -R root:root \/etc\/sssd<\/code><\/pre>\n\n\n\n
chmod 600 -R \/etc\/sssd<\/code><\/pre>\n\n\n\n
systemctl enable --now sssd<\/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: enabled)\n Active: active (running) since Thu 2020-08-27 19:31:25 EAT; 2h 22min ago\n Main PID: 663 (sssd)\n Tasks: 3 (limit: 2332)\n Memory: 7.6M\n CPU: 713ms\n CGroup: \/system.slice\/sssd.service\n \u251c\u2500663 \/usr\/sbin\/sssd -i --logger=files\n \u251c\u2500806 \/usr\/libexec\/sssd\/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files\n \u2514\u2500807 \/usr\/libexec\/sssd\/sssd_nss --uid 0 --gid 0 --logger=files\n\nAug 27 19:30:58 fedora32.kifarunix-demo.com systemd[1]: Starting System Security Services Daemon...\nAug 27 19:31:24 fedora32.kifarunix-demo.com sssd[663]: Starting up\nAug 27 19:31:24 fedora32.kifarunix-demo.com be[implicit_files][806]: Starting up\nAug 27 19:31:25 fedora32.kifarunix-demo.com nss[807]: Starting up\nAug 27 19:31:25 fedora32.kifarunix-demo.com systemd[1]: Started System Security Services Daemon.\n<\/code><\/pre>\n\n\n\n
Verify OpenLDAP Authentication via SSSD<\/a><\/h3>\n\n\n\n
id<\/strong><\/code> command.<\/p>\n\n\n\n
id janedoe<\/code><\/pre>\n\n\n\n
uid=10010(janedoe) gid=10010(janedoe) groups=10010(janedoe)<\/code><\/pre>\n\n\n\n
ssh -l janedoe localhost<\/code><\/pre>\n\n\n\n
The authenticity of host 'localhost (::1)' can't be established.\nECDSA key fingerprint is SHA256:JyAO5\/n9crE8qa923r0W0Ocw47LuVJFGuLZvnwRUM8k.\nAre you sure you want to continue connecting (yes\/no\/[fingerprint])? yes\nWarning: Permanently added 'localhost' (ECDSA) to the list of known hosts.\njanedoe@localhost's password: \n[janedoe@fedora32 ~]$<\/code><\/pre>\n\n\n\n
[janedoe@fedora32 ~]$ whoami\njanedoe\n[janedoe@fedora32 ~]$ pwd\n\/home\/janedoe\n[janedoe@fedora32 ~]$<\/code><\/pre>\n\n\n\n
Other Related Tutorials<\/h3>\n\n\n\n