{"id":2110,"date":"2019-01-20T19:28:58","date_gmt":"2019-01-20T16:28:58","guid":{"rendered":"http:\/\/kifarunix.com\/?p=2110"},"modified":"2019-01-20T19:50:44","modified_gmt":"2019-01-20T16:50:44","slug":"install-and-configure-openldap-server-on-fedora-29","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-openldap-server-on-fedora-29\/","title":{"rendered":"Install and Configure OpenLDAP server on Fedora 29"},"content":{"rendered":"<p>This guide will take you through the steps required to install and configure OpenLDAP server on Fedora 29. As you already know, OpenLDAP is an implementation of Light weight directory access protocol (LDAP). It provides a central management point for user information.<\/p>\n<h2>Install and Configure OpenLDAP server on Fedora 29<\/h2>\n<p>Update and upgrade your system packages;<\/p>\n<pre>dnf update\r\ndnf upgrade<\/code><\/pre>\n<p>To install LDAP server on Fedora 29, run the command below;<\/p>\n<pre class=\"screen\"><code class=\"command\">dnf install openldap-clients openldap-servers<\/code><\/pre>\n<p>Start and enable OpenLDAP server service to run system reboot.<\/p>\n<pre>systemctl enable slapd\r\nsystemctl start slapd<\/code><\/pre>\n<h2>Configure OpenLDAP server on Fedora 29<\/h2>\n<h3>Set the OpenLDAP administrator password.<\/h3>\n<p>This can be done using the <code>slappasswd<\/code> command which generate an encrypted password hash.<\/p>\n<pre>slappasswd \r\nNew password: password\r\nRe-enter new password: password \r\n<strong>{SSHA}MI\/malE7t763EWw7YiRzXsojGETmqMJq<\/strong><\/code><\/pre>\n<p>You can also set the password in a one line command; <code>slappasswd -h {SHA} -s <strong>password<\/strong><\/code>. Replace the &#8216;<strong>password<\/strong>&#8216; with your password.<\/p>\n<p>Save the generated hash since we will require it in a moment.<\/p>\n<h3>Configure OpenLDAP database<\/h3>\n<p>TO begin with, copy the sample OpenLDAP database configuration renaming it as follows;<\/p>\n<pre>cp \/usr\/share\/openldap-servers\/DB_CONFIG.example \/var\/lib\/ldap\/DB_CONFIG<\/code><\/pre>\n<p>Set the ownership of the LDAP database configuration directory <code>ldap<\/code> user.<\/p>\n<pre>chown -R ldap:ldap \/var\/lib\/ldap<\/code><\/pre>\n<h4>Import OpenLDAP basic schemas<\/h4>\n<p>Navigate to OpenLDAP schemas directory and import the cosine, nis and inetorgperson schemas.<\/p>\n<pre>cd \/etc\/openldap\/schema<\/code><\/pre>\n<pre>for schema in cosine.ldif nis.ldif inetorgperson.ldif; do ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f $schema; done<\/code><\/pre>\n<pre>SASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\nadding new entry \"cn=cosine,cn=schema,cn=config\"\r\n\r\nSASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\nadding new entry \"cn=nis,cn=schema,cn=config\"\r\n\r\nSASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\nadding new entry \"cn=inetorgperson,cn=schema,cn=config\"<\/code><\/pre>\n<p>Update the OpenLDAP database configuration file by modifying the values of the following attributes;<\/p>\n<ul>\n<li><code>olcSuffix<\/code> &#8211; set the value to your base domain<\/li>\n<li><code>olcRootDN<\/code> &#8211; set the value to your LDAP domain administrative entry<\/li>\n<li><code>olcRootPW<\/code> &#8211; This is set to your LDAP admin password generated above.<\/li>\n<\/ul>\n<p>Also, configure the access control list for the LDAP monitor backend (<code>olcDatabase\\=\\{1\\}monitor.ldif<\/code>) and the primary database backend (<code>olcDatabase={2}mdb.ldif<\/code>).<\/p>\n<p>All these modifications can be implemented using a single ldif file as shown below;<\/p>\n<pre>vim mod_domain.ldif<\/code><\/pre>\n<pre>dn: olcDatabase={1}monitor,cn=config\r\nchangetype: modify\r\nreplace: olcAccess\r\nolcAccess: {0}to * by dn.base=\"gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\"\r\n  read by dn.base=\"cn=Manager,dc=example,dc=com\" read by * none\r\n\r\ndn: olcDatabase={2}mdb,cn=config\r\nchangetype: modify\r\nreplace: olcSuffix\r\nolcSuffix: dc=example,dc=com\r\n\r\ndn: olcDatabase={2}mdb,cn=config\r\nchangetype: modify\r\nreplace: olcRootDN\r\nolcRootDN: cn=Manager,dc=example,dc=com\r\n\r\ndn: olcDatabase={2}mdb,cn=config\r\nchangetype: modify\r\nadd: olcRootPW\r\nolcRootPW: {SSHA}MI\/malE7t763EWw7YiRzXsojGETmqMJq\r\n\r\ndn: olcDatabase={2}mdb,cn=config\r\nchangetype: modify\r\nadd: olcAccess\r\nolcAccess: {0}to attrs=userPassword,shadowLastChange by\r\n  dn=\"cn=Manager,dc=example,dc=com\" write by anonymous auth by self write by * none\r\nolcAccess: {1}to dn.base=\"\" by * read\r\nolcAccess: {2}to * by dn=\"cn=Manager,dc=example,dc=com\" write by * read<\/code><\/pre>\n<p>These modifications can be implemented using the <code>ldapmodify<\/code> command.<\/p>\n<pre>ldapmodify -Y EXTERNAL -H ldapi:\/\/\/ -f mod_domain.ldif<\/code><\/pre>\n<pre>SASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\nmodifying entry \"olcDatabase={1}monitor,cn=config\"\r\n\r\nmodifying entry \"olcDatabase={2}mdb,cn=config\"\r\n\r\nmodifying entry \"olcDatabase={2}mdb,cn=config\"\r\n\r\nmodifying entry \"olcDatabase={2}mdb,cn=config\"\r\n\r\nmodifying entry \"olcDatabase={2}mdb,cn=config\"<\/code><\/pre>\n<p>You can use ldapsearch command to verify this.<\/p>\n<pre>ldapsearch  -Y EXTERNAL -H ldapi:\/\/\/ -b cn=config olcDatabase={2}mdb -LLL<\/code><\/pre>\n<pre>SASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\ndn: olcDatabase={2}mdb,cn=config\r\nobjectClass: olcDatabaseConfig\r\nobjectClass: olcMdbConfig\r\nolcDatabase: {2}mdb\r\nolcDbDirectory: \/var\/lib\/ldap\r\nolcDbIndex: objectClass eq,pres\r\nolcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub\r\nolcSuffix: dc=example,dc=com\r\nolcRootDN: cn=Manager,dc=example,dc=com\r\nolcRootPW: {SSHA}MI\/malE7t763EWw7YiRzXsojGETmqMJq\r\nolcAccess: {0}to attrs=userPassword,shadowLastChange by dn=\"cn=Manager,dc=exam\r\n ple,dc=com\" write by anonymous auth by self write by * none\r\nolcAccess: {1}to dn.base=\"\" by * read\r\nolcAccess: {2}to * by dn=\"cn=Manager,dc=example,dc=com\" write by * read<\/code><\/pre>\n<pre>ldapsearch  -Y EXTERNAL -H ldapi:\/\/\/ -b cn=config olcDatabase={1}monitor -LLL<\/code><\/pre>\n<pre>SASL\/EXTERNAL authentication started\r\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\r\nSASL SSF: 0\r\ndn: olcDatabase={1}monitor,cn=config\r\nobjectClass: olcDatabaseConfig\r\nolcDatabase: {1}monitor\r\nolcAccess: {0}to * by dn.base=\"gidNumber=0+uidNumber=0,cn=peercred,cn=external\r\n ,cn=auth\" read by dn.base=\"cn=Manager,dc=example,dc=com\" read by * none<\/code><\/pre>\n<p>Create the base domain and add it to LDAP to create your directory. Replace the domain entries approriately.<\/p>\n<pre>vim basedn.ldif<\/code><\/pre>\n<pre>dn: dc=example,dc=com\r\nobjectClass: top\r\nobjectClass: dcObject\r\nobjectclass: organization\r\no: Example Com\r\ndc: Example\r\n\r\ndn: cn=Manager,dc=example,dc=com\r\nobjectClass: organizationalRole\r\ncn: Manager\r\ndescription: LDAP Directory Manager\r\n\r\ndn: ou=People,dc=example,dc=com\r\nobjectClass: organizationalUnit\r\nou: People\r\n\r\ndn: ou=Group,dc=example,dc=com\r\nobjectClass: organizationalUnit\r\nou: Group<\/code><\/pre>\n<p>To add the Base domain entry, run the command below;<\/p>\n<pre>ldapadd -x -D cn=Manager,dc=example,dc=com -W -f basedn.ldif\r\nEnter LDAP Password: <strong>LDAP  manager's password set above<\/strong>\r\n\r\nadding new entry \"dc=example,dc=com\" \r\n\r\nadding new entry \"cn=Manager,dc=example,dc=com\"\r\n\r\nadding new entry \"ou=People,dc=example,dc=com\"<\/code><\/pre>\n<p>The OpenLDAP server configuration is about done.<\/p>\n<h3>Create OpenLDAP server User Accounts<\/h3>\n<p>Generate a password for the user using the <code>slappasswd<\/code> command;<\/p>\n<pre>slappasswd \r\nNew password: \r\nRe-enter new password: \r\n{SSHA}QLXFlVsiNY7bLgcwx8yurJqMZVaErD9b<\/code><\/pre>\n<p>Create an ldif file for specifying user attributes.<\/p>\n<pre>vim add_user.ldif<\/code><\/pre>\n<pre>dn: uid=amosm,ou=People,dc=example,dc=com\r\nobjectClass: inetOrgPerson\r\nobjectClass: posixAccount\r\nobjectClass: shadowAccount\r\ncn: Amos\r\nsn: Mibey\r\nuserPassword: {SSHA}QLXFlVsiNY7bLgcwx8yurJqMZVaErD9b\r\nloginShell: \/bin\/bash\r\nuidNumber: 10000\r\ngidNumber: 10000\r\nhomeDirectory: \/home\/amosm\r\n\r\ndn: cn=amosm,ou=Group,dc=example,dc=com\r\nobjectClass: posixGroup\r\ncn: Amos\r\ngidNumber: 10000\r\nmemberUid: amosm<\/code><\/pre>\n<pre>ldapadd -x -D cn=Manager,dc=example,dc=com -W -f add_user.ldif \r\nEnter LDAP Password: \r\nadding new entry \"uid=amosm,ou=People,dc=example,dc=com\"\r\n\r\nadding new entry \"cn=amosm,ou=Group,dc=example,dc=com\"<\/code><\/pre>\n<p>To verify that the user is created, you can use <code>ldapsearch<\/code> command to query its details.<\/p>\n<pre>ldapsearch -x uid=amosm -b dc=example,dc=com -LLL<\/code><\/pre>\n<pre>dn: uid=amosm,ou=People,dc=example,dc=com\r\nobjectClass: inetOrgPerson\r\nobjectClass: posixAccount\r\nobjectClass: shadowAccount\r\ncn: Amos\r\nsn: Mibey\r\nloginShell: \/bin\/bash\r\nuidNumber: 10000\r\ngidNumber: 10000\r\nhomeDirectory: \/home\/amosm\r\nuid: amosm<\/code><\/pre>\n<p>Well, that\u00a0 it all takes to install and configure OpenLDAP server on Fedora 29. It all seems good. Feel free to add more users and explore the full funtionality of OpenLDAP. Before we can wrap up, open the OpenLDAP server service on firewall to allow external access.<\/p>\n<pre><span class=\"crayon-c\">firewall-cmd --permanent --add-service=ldap<\/span>firewall-cmd --reload<\/code><\/pre>\n<p>All is left for doing is to configure the LDAP client to authenticate via the OpenLDAP server, We will cover this in our next tutorial. Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide will take you through the steps required to install and configure OpenLDAP server on Fedora 29. As you already know, OpenLDAP is an<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[285,121],"tags":[289,248],"class_list":["post-2110","post","type-post","status-publish","format-standard","hentry","category-directory-server","category-howtos","tag-fedora-29","tag-ldap","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2110"}],"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=2110"}],"version-history":[{"count":1,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2110\/revisions"}],"predecessor-version":[{"id":2112,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2110\/revisions\/2112"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}