Step by Step OpenLDAP Server Configuration On CentOS 7
Step by Step OpenLDAP Server Configuration On CentOS 7
Step by Step OpenLDAP Server Configuration On CentOS 7
Environment:
HOST NAME
IP ADDRESS
OS
PURPOSE
server.itzgeek.local
192.168.12.10
CentOS 7
LDAP Server
client.itzgeek.local
192.168.12.20
CentOS 7
LDAP Client
Prerequisites:
1. Make sure both LDAP server server.itzgeek.local (192.168.12.10) and LDAP
client client.itzgeek.local (192.168.12.20) are accessible.
2. Make an entry for each machines in /etc/hosts for name resolution.
vi /etc/hosts
192.168.12.10 server.itzgeek.local server
192.168.12.20 client.itzgeek.local client
or
If you plan to use server name instead of IP address, configure DNS server using article
on How to Configure DNS Server on RHEL7.
Here I will use IP address for all the configuration.
Install LDAP:
Install the following LDAP RPM packages to get started. Run below command on LDAP
server (server.itzgeek.local).
yum -y install openldap compat-openldap openldap-clients openldap-servers
openldap-servers-sql openldap-devel
Start the LDAP service and enable it for the auto start of service on system boot.
systemctl start slapd.service
systemctl enable slapd.service
0 0.0.0.0:389
0.0.0.0:*
LISTEN
0 :::389
:::*
LISTEN
Once you are done with the ldif file, send the configuration to the LDAP server.
ldapmodify -Y EXTERNAL
-H ldapi:/// -f db.ldif
Once you have updated the file, send the configuration to the LDAP server.
ldapmodify -Y EXTERNAL
-H ldapi:/// -f monitor.ldif
Lets create a self-signed certificate for our LDAP server, below command generates both
certificate and private key in /etc/openldap/certs/ directory.
openssl req -new -x509 -nodes -out /etc/openldap/certs/itzgeekldapcert.pem
-keyout /etc/openldap/certs/itzgeekldapkey.pem -days 365
Generating a 2048 bit RSA private key
...+++
.....................................+++
writing new private key to '/etc/openldap/certs/itzgeekldapkey.pem'
----You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
----Country Name (2 letter code) [XX]: XX
State or Province Name (full name) []: XX
Locality Name (eg, city) [Default City]: XXXXXX
Organization Name (eg, company) [Default Company Ltd]:ITzGeek
Organizational Unit Name (eg, section) []:IT Infra
Common Name (eg, your name or your server's hostname) []:server.itzgeek.local
Email Address []:admin@itzgeek.com
Create certs.ldif file to configure LDAP to use secure communication using a self-signed
certificate.
# vi certs.ldif
dn: cn=config
changetype: modify
replace: olcTLSCertificateFile
olcTLSCertificateFile: /etc/openldap/certs/itzgeekldapcert.pem
dn: cn=config
changetype: modify
replace: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/openldap/certs/itzgeekldapkey.pem
-H ldapi:/// -f certs.ldif
You should get the following message confirms the verification is complete.
ldapadd command will prompt you for the password of ldapadm (LDAP root user).
Output:
Enter LDAP Password:
adding new entry "dc=itzgeek,dc=local"
adding new entry "cn=ldapadm ,dc=itzgeek,dc=local"
adding new entry "ou=People,dc=itzgeek,dc=local"
adding new entry "ou=Group,dc=itzgeek,dc=local"