How to Build a Scalable OpenLDAP‑Based Unified Identity System for Enterprise Operations
This article walks through the evolution of a unified identity authentication system built on OpenLDAP, covering initial password‑management pain points, design decisions involving PAM and sudo, role‑based access control, multi‑IDC distributed deployment, security hardening with TLS and anti‑brute‑force measures, and practical host‑restriction techniques for reliable, secure operations.
Background
When a company grows beyond 50 servers, password management becomes chaotic: forgotten passwords, frequent changes, and mixed root accounts cause operational headaches, prompting the need for a unified identity authentication system.
Initial Requirements
Key demands emerged from real incidents: a single account should access all servers, password changes must propagate instantly, and sudo privileges need fine‑grained control.
Scenario A
New employee receives a uniquely named account with an initial password.
Scenario B
Employee can change the password without exposing it to administrators.
Scenario C‑F
Various permission models ranging from read‑only to full root access are required for different environments.
Implementation Overview
The chosen solution uses OpenLDAP as the core directory, supplemented by PAM for authentication and sudo for privilege escalation.
OpenLDAP Functions
Account information management (user ID, username, password, OU groups, etc.).
Authentication via LDAP client.
PAM Integration
Extends authentication to query the LDAP source in addition to local
passwdand
shadowfiles.
Sudo Integration
Privilege escalation via
sudo.
Default permissions defined in LDAP; temporary permissions also supported.
Role Classification
Roles are grouped as:
Administrator (root – SA role).
Business (oracle – DBA, service – OPS).
Observer (read_only – R&D).
Personal (LDAP personal accounts).
LDAP objects include users (people), groups (OU), and sudoers groups, linked via
gidNumberand
cnattributes.
Distributed Management
OpenLDAP supports a master‑slave architecture for multi‑IDC deployments. The master handles password change requests and log replication; slaves serve authentication queries locally. Secure inter‑IDC communication is achieved with IPsec VPN tunnels.
Security Enhancements
TLS encryption is enabled via OpenSSL on both server and client sides. Password‑brute‑force protection is added through the
pam_tally.somodule, locking accounts after five failed attempts for ten minutes.
<code>auth required pam_tally.so onerr=fail deny=5 unlock_time=600</code>Decoupling and Performance Optimizations
High‑frequency services can bypass LDAP for privileged accounts by configuring
nss_initgroups_ignoreusers, reducing LDAP query load and restoring performance.
Host‑Based Access Restrictions
OpenLDAP can enforce host restrictions by adding a
hostattribute to user entries and enabling
pam_check_host_attron clients, ensuring users can only log in from authorized machines.
<code>/etc/ldap/schema/ldapns.schema</code> <code>host:HostName</code> <code>pam_check_host_attr</code> <code>pam_filter</code> <code>nss_base_<map></code>Final Module Breakdown
Account Management
Centralized user and password storage.
Role‑based sudo permissions.
Architecture
Authentication delegated to LDAP servers.
Master‑slave synchronization for multi‑IDC.
Service decoupling to reduce LDAP load.
Security
TLS‑encrypted communication.
Login host restrictions.
Brute‑force protection.
Privilege escalation via sudo only after LDAP login.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.