Introduction
In this guide, we’ll set up an LDAP (Lightweight Directory Access Protocol) server, which will be used for centralized authentication and directory services. LDAP is commonly used in network environments to provide a single source of truth for user authentication and authorization.
Step 1: Install LDAP Server and Utilities
Begin by installing the LDAP server and associated utilities:
sudo apt update
sudo apt install slapd ldap-utils
Step 2: Export LDAP Database
To ensure the LDAP database is initialized correctly, export the LDAP database using the slapcat
command:
sudo slapcat
Step 3: Create Configuration Directory and Files
Create a directory for LDAP configuration files and navigate to it:
mkdir ldap_conf
cd ldap_conf
Create a file named basedn.ldif
to define the base DN (Distinguished Name) for your LDAP entries:
nano basedn.ldif
Add the following content:
dn: ou=people,dc=domain,dc=com
objectClass: organizationalUnit
ou: people
dn: ou=groups,dc=domain,dc=com
objectClass: organizationalUnit
ou: groups
Next, create a file named username.ldif
to define an example user entry:
nano username.ldif
Add the following content, replacing placeholder values with actual user details:
dn: uid=username,ou=people,dc=domain,dc=com
objectClass: top
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
cn: userFirstName userLastName
givenName: userFirstName
sn: userLastName
mail: userFirstName.userLastName@domain.com
userPassword: {SSHA}genEratedencRyptedp@ssw0rd
loginShell: /bin/bash
homeDirectory: /home/username
uidNumber: 3010
gidNumber: 3010
Step 4: Add LDAP Entries
Add the base DN and user entries to the LDAP directory using the ldapadd
command:
sudo ldapadd -x -D cn=admin,dc=domain,dc=com -W -f basedn.ldif
sudo ldapadd -x -D cn=admin,dc=domain,dc=com -W -f username.ldif
Step 5: Configure UFW for LDAP
If necessary, configure the firewall to allow LDAP traffic on port 389:
sudo ufw allow 389/tcp
Conclusion
Congratulations! You’ve successfully set up an LDAP server and added an example user entry. LDAP provides a centralized and scalable solution for managing user authentication and authorization in your network environment. In the next guide, we’ll configure the Inspircd IRC server.