Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| infra:ldap [2026/05/03 18:40] – external edit 127.0.0.1 | infra:ldap [2026/11/20 13:18] (current) – Rebuild LDAP reference; add ID ranges verified 2026-11-20 threepio | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== LDAP in a nutshell | + | ====== LDAP ====== |
| - | You configure a database /?/ of users /that you add manually/ and tell other services, like peertube /or the linux login system even/, to look for the individuals in the ldap directories. This way an admin does not make an accound for 500 different users in 500 different servers. The user is made in ldap, and then some to-be-integrated server, like Mastodon for example, is told to get the users email, password, phone number etc from LDAP. | + | ABI's directory service. It holds user accounts, groups, SSH public keys and mail addresses; SSH logins, Git, the wiki and the ticketing system all authenticate against it. |
| - | ===== Why did we re-set-up our ldap. ===== | + | **ID ranges and storage facts verified against live systems: 2026-11-20.** Install and schema details below come from the original setup notes. |
| - | Because our dear sysadmin /not telling names/ set it up on quick hand, and overlooked the transport layer security /TLS/ and plus our users didnt happen to have emails and phone numbers. So in order to not doubt our ldap when integrating new things with it - we decided to set up a new normies | + | ^ Component ^ Value ^ |
| + | | Server | OpenLDAP 2.6 ('' | ||
| + | | Address | '' | ||
| + | | Database | MDB (memory-mapped) | | ||
| + | | Base DN | '' | ||
| + | | Encryption | LDAPS with a self-signed certificate | | ||
| + | | Management tools | [[https:// | ||
| - | The main points were: - ldap shall have TLS - info such as email, phone numbers, names, etc | + | ===== Directory layout ===== |
| - | We also wanted to use PostgreSQL as the database but turns out that’s not how LDAP works. So we use MDB /memory mapped database/ instead. | + | < |
| + | dc=abi, | ||
| + | cn=admin | ||
| + | ou=Users | ||
| + | ou=Groups | ||
| + | ou=Machines | ||
| + | ou=Idmap | ||
| + | ou=Services | ||
| + | </code> | ||
| - | ===== Components ===== | + | A user entry carries '' |
| - | * Server: OpenLDAP 2.6 /slapd daemon/ | + | ===== ID ranges ===== |
| - | * Database: MDB | + | |
| - | * Directory base: abi.am or dc=abi,dc=am | + | |
| - | * Security: LDAPS /for tls/ | + | |
| - | * Certificate: | + | |
| - | <code sh> | + | Only the start values are enforced |
| - | The structure / given by ldapsearch -x -b " | + | |
| - | dc=abi,dc=am | + | ^ Range ^ Used for ^ Defined by ^ |
| - | | + | | 10000+ | Human users ('' |
| - | | + | | 10000+ | Per-user groups ('' |
| - | |-> cn=antranigv,ou=admins,dc=abi, | + | | 14999 | One-off account, excluded from the next-ID calculation | [[infra: |
| - | | + | | 15000-15999 | Shared and project groups | Convention (e.g. 15000 '' |
| - | </ | + | | 50000+ | Bot accounts | Convention; provisioning via '' |
| + | | 59999 | Shared group '' | ||
| + | |||
| + | * Users and their personal groups are allocated as highest + 1 and grow upward; there is no configured maximum. | ||
| + | * A bot gets a personal group whose gid equals its uid, plus membership in the shared '' | ||
| + | * The 15000-15999 and 50000+ ranges are conventions, not enforced by any tool. Treat this page as their definition for new allocations, and update it if a range changes. | ||
| + | |||
| + | ===== Adding and managing users ===== | ||
| + | |||
| + | The procedure lives on [[infra: | ||
| - | ==== Install | + | ===== Install and configure ===== |
| <code sh> | <code sh> | ||
| Line 38: | Line 56: | ||
| </ | </ | ||
| - | ==== Generate | + | === TLS certificate |
| <code sh> | <code sh> | ||
| Line 44: | Line 62: | ||
| cd / | cd / | ||
| - | # generate the key | ||
| openssl genrsa -out ldap-server.key 2048 | openssl genrsa -out ldap-server.key 2048 | ||
| - | |||
| - | # generate the csr /using that key/ | ||
| - | # csr = certificate signing request | ||
| openssl req -new -key ldap-server.key -out ldap-server.csr \ | openssl req -new -key ldap-server.key -out ldap-server.csr \ | ||
| -subj "/ | -subj "/ | ||
| - | |||
| - | # generate certificate /using that csr, and the key/ | ||
| openssl x509 -req -days 365 -in ldap-server.csr \ | openssl x509 -req -days 365 -in ldap-server.csr \ | ||
| -signkey ldap-server.key -out ldap-server.crt | -signkey ldap-server.key -out ldap-server.crt | ||
| - | # permissions: | ||
| chmod 600 ldap-server.key | chmod 600 ldap-server.key | ||
| chmod 644 ldap-server.crt | chmod 644 ldap-server.crt | ||
| Line 62: | Line 73: | ||
| </ | </ | ||
| - | ==== Create the database | + | === Database |
| <code sh> | <code sh> | ||
| - | mkdir -p / | + | mkdir -p / |
| chown -R ldap:ldap / | chown -R ldap:ldap / | ||
| chmod 700 / | chmod 700 / | ||
| </ | </ | ||
| - | ===== Configuring ===== | + | === Configuration files === |
| - | We have 3 main config files we work with. - slapd.conf | + | ^ File ^ Purpose ^ |
| + | | ''/ | ||
| + | | '' | ||
| + | | ''/ | ||
| - | * base-setup.ldif | + | Essential |
| - | * ldap.conf '' | + | |
| - | + | ||
| - | to see or modify them just run | + | |
| - | + | ||
| - | <code sh> | + | |
| - | vim / | + | |
| - | vim / | + | |
| - | vim / | + | |
| - | </ | + | |
| < | < | ||
| - | # slapd.conf | + | include |
| - | + | include | |
| - | | + | include |
| - | include | + | |
| - | include | + | |
| - | + | ||
| - | pidfile | + | |
| - | argsfile | + | |
| - | + | ||
| - | # Load dynamic backend modules: | + | |
| - | modulepath | + | |
| - | moduleload | + | |
| - | + | ||
| - | TLSCertificateFile | + | |
| - | TLSCertificateKeyFile | + | |
| - | TLSCACertificateFile | + | |
| - | + | ||
| - | # Database Configuration | + | |
| - | database | + | modulepath |
| - | | + | moduleload |
| - | rootdn | + | |
| - | rootpw | + | |
| - | directory | + | TLSCertificateFile |
| + | TLSCertificateKeyFile | ||
| + | TLSCACertificateFile | ||
| - | index | + | database |
| - | index cn,sn,uid,mail eq,sub | + | suffix |
| + | rootdn | ||
| + | rootpw | ||
| + | directory | ||
| - | access to attrs=userPassword | + | index |
| - | by self write | + | index |
| - | by anonymous auth | + | |
| - | by * none | + | |
| - | | + | access to attrs=userPassword |
| - | by self write | + | by self write |
| - | by users read | + | by anonymous auth |
| - | by * read | + | by * none |
| - | database monitor | + | access to * |
| - | | + | by self write |
| - | by dn.exact=" | + | by users read |
| - | by * read | + | |
| </ | </ | ||
| - | < | + | Import |
| - | base-setup.ldif | + | |
| - | + | ||
| - | # Domain | + | |
| - | + | ||
| - | dn: dc=abi, | + | |
| - | objectClass: | + | |
| - | objectClass: | + | |
| - | objectClass: | + | |
| - | o: abi.am | + | |
| - | dc: abi | + | |
| - | + | ||
| - | + | ||
| - | # Organizational unit ADMINS /and their interns/ | + | |
| - | + | ||
| - | dn: ou=admins, | + | |
| - | objectClass: | + | |
| - | ou: admins | + | |
| - | + | ||
| - | + | ||
| - | # Organizational unit PEOPLE | + | |
| - | + | ||
| - | dn: ou=people, | + | |
| - | objectClass: | + | |
| - | ou: people | + | |
| - | + | ||
| - | + | ||
| - | # Antranig /the real admin/ | + | |
| - | + | ||
| - | dn: cn=antranigv, | + | |
| - | objectClass: | + | |
| - | cn: Antranig | + | |
| - | sn: sysadmin | + | |
| - | mail: antranigv@abi.am | + | |
| - | userPassword: | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | # import | + | |
| - | ldapadd -x -D " | + | |
| - | + | ||
| - | # to test, show all directory entries | + | |
| - | ldapsearch -x -b " | + | |
| - | + | ||
| - | # or entries + hashed passwords | + | |
| - | ldapsearch -x -D " | + | |
| - | + | ||
| - | # or authenticate | + | |
| - | ldapwhoami -x -D " | + | |
| - | # TLS test: same auth but with encryption /-ZZ/ | + | |
| - | ldapwhoami -x -D " | + | |
| - | </ | + | |
| - | + | ||
| - | And finally | + | |
| <code sh> | <code sh> | ||
| + | ldapadd -x -D " | ||
| service slapd start | service slapd start | ||
| - | + | sockstat -l | grep 389 | |
| - | # Check if its running | + | |
| - | + | ||
| - | ps aux | grep slapd | + | |
| - | sockstat -l | greo 389 | + | |
| </ | </ | ||
| - | ===== Common actions | + | ===== Schema notes ===== |
| - | ==== Adding | + | * '' |
| + | * '' | ||
| + | * Group ownership ('' | ||
| - | make a file for the new user eg ani.ldif (preferrably in / | + | ===== Common operations ===== |
| - | Example of a user : | + | === Change a user' |
| - | + | ||
| - | <code ldif> | + | |
| - | dn: uid=ani,ou=Users,dc=abi,dc=am | + | |
| - | objectClass: | + | |
| - | objectClass: | + | |
| - | objectClass: | + | |
| - | sn: Hakobyan | + | |
| - | mail: ani.hakobyan@abi.am | + | |
| - | uidNumber: 10037 | + | |
| - | gidNumber: 10037 | + | |
| - | homeDirectory: | + | |
| - | loginShell: /bin/bash | + | |
| - | gecos: ani | + | |
| - | description: | + | |
| - | sshPublicKey: | + | |
| - | userPassword:: | + | |
| - | uid: ani | + | |
| - | cn: Ani | + | |
| - | </ | + | |
| - | + | ||
| - | and import the user like this | + | |
| < | < | ||
| - | ldapadd -x -H ldaps:// | + | dn: uid=USERNAME, |
| - | </ | + | |
| - | + | ||
| - | ==== modify user email ==== | + | |
| - | + | ||
| - | make a modify-email.ldif with the following content | + | |
| - | + | ||
| - | < | + | |
| - | dn: uid=ani, | + | |
| changetype: modify | changetype: modify | ||
| replace: mail | replace: mail | ||
| - | mail: ani@abi.am | + | mail: user@abi.am |
| </ | </ | ||
| - | |||
| - | apply changes with | ||
| < | < | ||
| Line 246: | Line 151: | ||
| </ | </ | ||
| - | then you can search for the user by email | + | === Change a password === |
| < | < | ||
| - | ldapsearch | + | ldappasswd |
| </ | </ | ||
| - | ==== change password for someone, for example Antranig ==== | + | === Back up the database |
| < | < | ||
| - | ldappasswd | + | / |
| </ | </ | ||
| - | ==== backup database ==== | + | === Verify authentication and TLS === |
| < | < | ||
| - | / | + | ldapwhoami |
| - | </ | + | ldapwhoami |
| - | + | ldapsearch | |
| - | Add many | + | |
| - | + | ||
| - | <code sh> | + | |
| - | + | ||
| - | for file in organizational_units/ | + | |
| - | echo " | + | |
| - | ldapadd -y pass \ | + | |
| - | | + | |
| - | | + | |
| - | done | + | |
| - | + | ||
| - | for file in groups/ | + | |
| - | echo " | + | |
| - | ldapadd | + | |
| - | | + | |
| - | | + | |
| - | done | + | |
| - | + | ||
| - | for file in users/ | + | |
| - | echo " | + | |
| - | ldapadd | + | |
| - | -D "cn=admin,dc=abi, | + | |
| - | | + | |
| - | done | + | |
| </ | </ | ||
| - | ===== in / | + | ===== See also ===== |
| - | we have\\ | + | * [[infra: |
| - | base.ldif\\ | + | * [[infra: |
| - | / | + | * [[infra:overview|Infrastructure Overview]] |
| - | the projects have members and owners.\\ | + | |
| - | '' | + | |
| - | '' | + | |
| - | /users\\ | + | |
| - | users have objectclass sshPublicKey which comes from a custion schema sshPublicKey. Also the field “email” has been hardcoded into some objectclass that our users use so we can have '' | + | |
| - | / | + | |
| - | /groups | + | |
