16.7 C
Texas
angeloma
Senior Writer and partner

How to install OpenLDAP on Ubuntu 18.04?

OpenLDAP is a free, open-source implementation of the Lightweight Directory Access Protocol (LDAP). With it, you can get a centralized authentication between the members of a network. So, I will show you how to install OpenLDAP on Ubuntu 18.04.

Let’s do it.

0. What you need

Installing OpenLDAP on Ubuntu 18.04 is not a really complicated matter, however, it is necessary to have a basic knowledge about the use of the terminal.

Also, your user needs to be able to execute commands with sudo because some commands require root.

- Advertisement -

With this in mind, you can start the installation without problems.

1. Upgrade the system

In the first place, you need to upgrade the system. It is recommended to get the latest security patches on your system.

:~$ sudo apt update && sudo apt upgrade

1.- Upgrading the system
1.- Upgrading the system

Now, you can continue.

2. Set the hostname

The first step is to define the hostname. Run this command:

:~$ sudo hostnamectl set-hostname ldap.osradar.local

And add it to your /etc/hosts file

:~$ echo "192.168.250.6 ldap.osradar.com" | sudo tee -a /etc/hosts

2.- Setting the hostname
2.- Setting the hostname

3. Install OpenLDAP

A great advantage of OpenLDAP is that its packages are in the official Ubuntu repositories, which makes installation easy. Just write the following.

:~$ sudo apt install slapd ldap-utils

2.- Install OpenLDAP from the Ubuntu main repository
3.- Install OpenLDAP from the Ubuntu main repository

After downloading the package and during installation you will have to define and confirm the root password.

3.- Setting the root password
4.- Setting the root password

If you wish to verify that the installation has been carried out effectively. You can use the following command:

:~$ sudo slapcat

4.- Checking the installation
5.- Checking the installation

As you can see in the image above, OpenLDAP is installed correctly.

4. Add base dn for Users and Groups

it is now necessary to configure OpenLDAP. To do this, the first step is to add to base DN for users and groups.

Create a file called basedn.ldif in your home folder or wherever you want.

:~$ nano basedn.ldif

5.- Creating dn file for OpenLDAP user and group
5.- Creating dn file for OpenLDAP user and group

And add the following:

dn: ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups

Of course, replace example and com, for your domain properties.

Next, add the configuration file. Run:

:~$ ldapadd -x -D cn=admin,dc=osradar,dc=local -W -f basedn.ldif

6.- Creating the new configuration file
6.- Creating the new configuration file

Next, install phpLDAPadmin.

5. Install phpLDAPadmin

In order to manage OpenLDAP in a quick and easy way is that you have to install phpLDAPadmin. Let’s do it.

First, install some necessary packages. Among them are Apache web server and PHP.

:~$ sudo apt install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear

7.- Installing some required package for phpldapadmin
7.- Installing some required package for phpLDAPadmin

Next, it is necessary to enable the php7.2-cgi extension. Then, restart Apache service.

:~$ sudo a2enconf php7.2-cgi
:~$ sudo systemctl reload apache2

8.- Enable a necessary php extension
8.- Enable a necessary PHP extension

Then install phpLDAPadmin.

:~$ sudo apt install phpldapadmin

9.- Installing phpLDAPadmin
9.- Installing phpLDAPadmin

The next step is to modify the permissions in the phpLDAPadmin configuration file to receive requests from network members.

:~$ sudo nano /etc/apache2/conf-enabled/phpldapadmin.conf

And leave it as I show you in the picture.

10.- Configuring phpLDAPadmin
10.- Configuring phpLDAPadmin

With this, we are simply telling phpLDAPadmin to accept requests from network members.

Then, restart Apache.

:~$ sudo systemctl restart apache2

If you use ufw, you must open ports 80 and 443.

:~$ sudo ufw allow 80
:~$ sudo ufw allow 443

11.- Preparing the firewall
11.- Preparing the firewall

Finally, open your favorite web browser and go to http://IP_SERVER_OR_DOMAIN/phpldapadmin

12.- phpLDAPadmin main page
12.- phpLDAPadmin main page

Next, log in.

13.- Add the credentials on phpLDAPadmin
13.- Add the credentials on phpLDAPadmin

Finally, you will see this.

14.- phpLDAPadmin installed
14.- phpLDAPadmin installed

And that’s it.

Conclusion

As you can see OpenLDAP is easy to install and configure in Ubuntu, it just remains that you can configure it to your needs.

Please share this article with friends.

 

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article