Thursday, October 16, 2025
HomeGuest BlogsConfigure LDAP Client on Ubuntu 22.04|20.04|18.04|16.04

Configure LDAP Client on Ubuntu 22.04|20.04|18.04|16.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

This is a guide on how to configure anĀ Ubuntu 22.04|20.04|18.04|16.04 LTS servers to authenticate against an LDAP directory server. LDAP is a lightweight client-server protocol for accessing directory services, specifically X.500-based directory services.

I expect you already have a running LDAP server, if not, use our guides below to set it up:

Once you have LDAP server configured and user accounts added, you can proceed to install and configure LDAP client.

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Install and Configure LDAP Client on Ubuntu 22.04|20.04|18.04|16.04

Add LDAP server address toĀ /etc/hostsĀ file if you don’t have an active DNS server in your network.

$ sudo vim /etc/hosts
192.168.18.50 ldap.example.com

Install LDAP client utilities on your Ubuntu system:

sudo apt -y install libnss-ldap libpam-ldap ldap-utils

Begin configuring the settings to look like below

1.Ā Set LDAP URI- This can be IP address or hostname

ldap client ubuntu 18.04 add uri min

2.Ā Set a Distinguished name of the search base

ldap client ubuntu 18.04 set search base distinguished name min

3.Ā Select LDAP versionĀ 3

ldap client ubuntu 18.04 set ldap version min

4.Ā SelectĀ YesĀ forĀ Make local root Database admin

ldap client ubuntu 18.04 make local root database admin min

5.Ā AnswerĀ NoĀ forĀ Does the LDAP database require login?

ldap client ubuntu 18.04 does ldap require login no min

6.Ā Set LDAP account for root, something likeĀ cn=admin,cd=example,cn=com

ldap client ubuntu 18.04 set admin ldap account min

7.Ā Provide LDAP root account Password

ldap client ubuntu 18.04 enter ldap admin pass min

After the installation, editĀ /etc/nsswitch.confand add ldap authentication toĀ passwdĀ andĀ groupĀ lines.

passwd: compat systemd ldap
group: compat systemd ldap
shadow: compat

Modify the fileĀ /etc/pam.d/common-password. RemoveĀ use_authtokĀ on lineĀ 26Ā to look like below.

password [success=1 user_unknown=ignore default=die] pam_ldap.so try_first_pass

Enable creation of home directory on first login by adding the following line to the end of fileĀ /etc/pam.d/common-session

session optional pam_mkhomedir.so skel=/etc/skel umask=077

See below screenshot:

ldap client enable home creation min

Test by switching to a user account on LDAP

root@server1:~# sudo su - jmutai
Creating directory '/home/jmutai'.
jmutai@server1:~$ id
uid=10000(jmutai) gid=10000(sysadmins) groups=10000(sysadmins)

That’s all. If you need advanced centralized user management platform, see

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS