🛡️ Complete Guide: LDAP Configuration with DNS, SSH & FTP on Debian
In this guide, we’ll walk through setting up an LDAP server with client authentication over a secure Debian infrastructure, complete with DNS resolution, SSH login, and FTP access.
- Domain:
server.local - LDAP Server IP:
192.168.29.237 - LDAP Client IP:
192.168.29.22 - Use static IP addresses on both server and client.
On the LDAP server:
hostnamectl set-hostname ns.server.local
rebootDNS is essential for resolving hostnames like server.local and ldap.server.local.
apt install bind9 dnsutilsEdit:
vim /etc/bind/named.conf.localmkdir /etc/bind/zones
vim /etc/bind/zones/forward.server.localserver.local. IN A 192.168.29.237
ldap.server.local. IN A 192.168.29.237vim /etc/hosts192.168.29.237 server.local ldap.server.localsystemctl restart bind9
systemctl enable named.servicenslookup server.local 192.168.29.237
nslookup ldap.server.local 192.168.29.237vim /etc/resolv.confnameserver 192.168.29.237✅ DNS is ready!
apt install slapd ldap-utilsdpkg-reconfigure slapdSample answers:
- Omit OpenLDAP server configuration? →
No - DNS Domain Name →
server.local - Organization name →
server - Administrator Password → 123
- Confirm Password → 123
- Do you want the database removed when slapd is purged? →
No - Move old database? →
Yes
``
`
BASE dc=server,dc=local
URI ldap://ldap.server.localRun:
ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn
ldapsearch -x -LLL -H ldap:/// -b dc=server,dc=local dn
ldapwhoami -x
ldapwhoami -x -D cn=admin,dc=server,dc=local -W
ldapwhoami -Y EXTERNAL -H ldapi:/// -QGenerate password:
slappasswdSample hashed output:
{SSHA}D88BroZNxE34q7ERv9fq6VVDSQ98xYWS
Create and edit:
vim users.ldifAdd organizational units and users.
ldapadd -x -D cn=admin,dc=server,dc=local -W -f users.ldifVerify:
ldapsearch -x -LLL -b dc=server,dc=local '(uid=ankit)' cn gidNumberldappasswd -x -D cn=admin,dc=server,dc=local -W -S uid=ankit,ou=people,dc=server,dc=localvim /etc/pam.d/common-authAdd:
auth sufficient pam_ldap.sovim /etc/pam.d/common-sessionAdd:
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022apt install nslcd libpam-ldapdDuring setup, use:
- URI:
ldap://ldap.server.local - Base DN:
dc=server,dc=local
vim /etc/nslcd.conf
Add:
binddn cn=admin,dc=server,dc=local
bindpw 123Restart:
systemctl restart nslcd.service✅ LDAP authentication is now active!
getent passwd ankit
id ankit
apt install libnss-ldapd libpam-ldapd ldap-utilsvim /etc/pam.d/common-sessionAdd:
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022su - ankitIf /home/ankit is created — success!
vim /etc/ssh/sshd_configEnsure:
UsePAM yessystemctl restart sshdssh ankit@192.168.29.237apt install vsftpdvim /etc/pam.d/vsftpdAdd:
auth required pam_ldap.so
account required pam_ldap.so
session required pam_loginuid.sovim /etc/vsftpd.confSet:
local_enable=YES
write_enable=YES
pam_service_name=vsftpdsystemctl restart vsftpdapt install ftpftp 192.168.29.237With this configuration:
- ✅ LDAP users are authenticated system-wide
- ✅ DNS resolves correctly
- ✅ SSH access is LDAP-enabled
- ✅ FTP works securely via LDAP
Now your Debian infrastructure is centralized, secure, and efficient.






























