Zentrale Benutzerverwaltung mit OpenLDAP und SSS: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
| Zeile 8: | Zeile 8: | ||
= Grundkonfiguration = | = Grundkonfiguration = | ||
Die folgende Tabelle führt die exakten englischen Abfragen auf, die bei '''dpkg-reconfigure slapd''' erscheinen, sowie die empfohlenen Eingaben für die it213.int Umgebung. | Die folgende Tabelle führt die exakten englischen Abfragen auf, die bei '''dpkg-reconfigure slapd''' erscheinen, sowie die empfohlenen Eingaben für die it213.int Umgebung. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Zeile 34: | Zeile 32: | ||
|} | |} | ||
= OpenLDAP Manuelle Einrichtung (OLC)= | = OpenLDAP Manuelle Einrichtung (OLC) = | ||
[[OpenLDAP Manuelle Einrichtung (OLC)]] | [[OpenLDAP Manuelle Einrichtung (OLC)]] | ||
= | = Server Vorbereitung = | ||
== | == Grundstruktur == | ||
{{#drawio:it213-ldap}} | |||
= | === Erstellen === | ||
== | * cat <<EOF > /root/struktur.ldif | ||
* | <pre> | ||
dn: ou=users,dc=it213,dc=int | |||
objectClass: organizationalUnit | |||
ou: users | |||
= | dn: ou=groups,dc=it213,dc=int | ||
objectClass: organizationalUnit | |||
ou: groups | |||
dn: ou=hosts,dc=it213,dc=int | |||
objectClass: organizationalUnit | |||
ou: hosts | |||
dn: ou=sudo,dc=it213,dc=int | |||
objectClass: organizationalUnit | |||
ou: sudo | |||
</pre> | |||
EOF | |||
== Anlegen == | === Anlegen === | ||
* ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f struktur.ldif | * ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f /root/struktur.ldif | ||
= Ldapscripts = | = Ldapscripts = | ||
| Zeile 96: | Zeile 76: | ||
MSUFFIX="ou=hosts" | MSUFFIX="ou=hosts" | ||
BINDDN="cn=admin,dc=it213,dc=int" | BINDDN="cn=admin,dc=it213,dc=int" | ||
BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd" | BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd" | ||
GIDSTART="10000" | GIDSTART="10000" | ||
UIDSTART="10000" | UIDSTART="10000" | ||
=== Password Datei === | === Password Datei === | ||
* echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd | * echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd | ||
== | == Management == | ||
=== Struktur === | === Struktur === | ||
{{#drawio: | {{#drawio:it213-2}} | ||
=== Gruppen | === Gruppen und Benutzer === | ||
* ldapaddgroup it | * ldapaddgroup it | ||
* ldapadduser thomas it | * ldapadduser thomas it | ||
* ldapadduser tina it | * ldapadduser tina it | ||
* ldapsetpasswd thomas | * ldapsetpasswd thomas | ||
* ldapsetpasswd tina | * ldapsetpasswd tina | ||
= | = Client Anbindung via SSSD = | ||
Da sudo-ldap veraltet ist, nutzen wir SSSD für NSS, PAM und Sudo. | |||
== Installation == | == Installation == | ||
* | * apt install sssd libnss-sss libpam-sss libsss-sudo | ||
== | == Konfiguration == | ||
* | * vim /etc/sssd/sssd.conf | ||
<pre> | |||
[sssd] | |||
services = nss, pam, sudo | |||
domains = it213.int | |||
== | [domain/it213.int] | ||
id_provider = ldap | |||
auth_provider = ldap | |||
sudo_provider = ldap | |||
= | ldap_uri = ldap://ldap.it213.int | ||
ldap_search_base = dc=it213,dc=int | |||
ldap_sudo_search_base = ou=sudo,dc=it213,dc=int | |||
ldap_id_use_start_tls = false | |||
== | cache_credentials = True | ||
ldap_tls_reqcert = allow | |||
</pre> | |||
* chmod 600 /etc/sssd/sssd.conf | |||
* | * systemctl restart sssd | ||
== | == System Integration == | ||
=== nsswitch.conf === | |||
* vim /etc/nsswitch.conf | |||
passwd: files sss | |||
group: files sss | |||
* | shadow: files sss | ||
sudoers: files sss | |||
== | === PAM mkhomedir === | ||
* pam-auth-update --enable mkhomedir | |||
= | = Sudo im LDAP = | ||
* | == Sudo-Regeln anlegen == | ||
Damit SSSD Sudo-Regeln findet, müssen diese als Objekte im LDAP existieren. | |||
* cat <<EOF > /root/sudo_rules.ldif | |||
<pre> | |||
dn: cn=defaults,ou=sudo,dc=it213,dc=int | |||
objectClass: sudoRole | |||
cn: defaults | |||
sudoOption: env_reset | |||
sudoOption: mail_badpass | |||
sudoOption: secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |||
== | dn: cn=%sudo,ou=sudo,dc=it213,dc=int | ||
objectClass: sudoRole | |||
cn: %sudo | |||
sudoUser: %sudo | |||
sudoHost: ALL | |||
sudoRunAsUser: ALL | |||
sudoRunAsGroup: ALL | |||
sudoCommand: ALL | |||
</pre> | |||
EOF | |||
== | * ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f /root/sudo_rules.ldif | ||
= | == Gruppenzuweisung == | ||
* ldapaddgroup sudo | * ldapaddgroup sudo | ||
* ldapaddusertogroup thomas sudo | * ldapaddusertogroup thomas sudo | ||
* ldapaddusertogroup tina sudo | * ldapaddusertogroup tina sudo | ||
= Tests und Kontrolle = | |||
* | == Identität == | ||
* getent group it | |||
* getent passwd thomas | |||
* | * id tina | ||
* | |||
== Sudo Check == | |||
* su - thomas | * su - thomas | ||
* sudo -l | * sudo -l | ||
* sudo whoami | * sudo whoami | ||
== Dienstverwaltung == | |||
* systemctl status slapd | |||
* systemctl status sssd | |||
* netstat -lntp | grep slapd | |||
Version vom 2. April 2026, 06:21 Uhr
Installation
- passwort nach wahl festlegen
- apt update
- apt install slapd ldap-utils
- slapd
- OpenLDAP Standalone Server
- ldap-utils
- Utilities zum Zugriff auf den LDAP Server
Grundkonfiguration
Die folgende Tabelle führt die exakten englischen Abfragen auf, die bei dpkg-reconfigure slapd erscheinen, sowie die empfohlenen Eingaben für die it213.int Umgebung.
| Debconf Question | Description | Recommended Input / Choice |
|---|---|---|
| Omit OpenLDAP server configuration? | Determines if the installer should skip creating a database. | No |
| DNS domain name: | Used to construct the base DN of the LDAP directory. | it213.int |
| Organization name: | The name of the organization to use in the base DN. | it213 |
| Administrator password: | The password for the admin entry (cn=admin). | 123Start$ |
| Confirm password: | Re-enter the password for verification. | 123Start$ |
| Database backend to use: | The storage engine for the LDAP database. | MDB |
| Do you want the database to be removed when slapd is purged? | Whether to delete the data if the package is completely removed. | No |
| Move old database? | If a database already exists, should it be moved aside? | Yes |
| Allow LDAPv2 protocol? | Support for the obsolete LDAP version 2. | No |
OpenLDAP Manuelle Einrichtung (OLC)
OpenLDAP Manuelle Einrichtung (OLC)
Server Vorbereitung
Grundstruktur
Erstellen
- cat <<EOF > /root/struktur.ldif
dn: ou=users,dc=it213,dc=int objectClass: organizationalUnit ou: users dn: ou=groups,dc=it213,dc=int objectClass: organizationalUnit ou: groups dn: ou=hosts,dc=it213,dc=int objectClass: organizationalUnit ou: hosts dn: ou=sudo,dc=it213,dc=int objectClass: organizationalUnit ou: sudo
EOF
Anlegen
- ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f /root/struktur.ldif
Ldapscripts
Installation
- apt install ldapscripts
Konfiguration
Hauptkonfiguration
- cat /etc/ldapscripts/ldapscripts.conf
SERVER="ldap://ldap.it213.int" SUFFIX="dc=it213,dc=int" GSUFFIX="ou=groups" USUFFIX="ou=users" MSUFFIX="ou=hosts" BINDDN="cn=admin,dc=it213,dc=int" BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd" GIDSTART="10000" UIDSTART="10000"
Password Datei
- echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd
Management
Struktur
Gruppen und Benutzer
- ldapaddgroup it
- ldapadduser thomas it
- ldapadduser tina it
- ldapsetpasswd thomas
- ldapsetpasswd tina
Client Anbindung via SSSD
Da sudo-ldap veraltet ist, nutzen wir SSSD für NSS, PAM und Sudo.
Installation
- apt install sssd libnss-sss libpam-sss libsss-sudo
Konfiguration
- vim /etc/sssd/sssd.conf
[sssd] services = nss, pam, sudo domains = it213.int [domain/it213.int] id_provider = ldap auth_provider = ldap sudo_provider = ldap ldap_uri = ldap://ldap.it213.int ldap_search_base = dc=it213,dc=int ldap_sudo_search_base = ou=sudo,dc=it213,dc=int ldap_id_use_start_tls = false cache_credentials = True ldap_tls_reqcert = allow
- chmod 600 /etc/sssd/sssd.conf
- systemctl restart sssd
System Integration
nsswitch.conf
- vim /etc/nsswitch.conf
passwd: files sss group: files sss shadow: files sss sudoers: files sss
PAM mkhomedir
- pam-auth-update --enable mkhomedir
Sudo im LDAP
Sudo-Regeln anlegen
Damit SSSD Sudo-Regeln findet, müssen diese als Objekte im LDAP existieren.
- cat <<EOF > /root/sudo_rules.ldif
dn: cn=defaults,ou=sudo,dc=it213,dc=int objectClass: sudoRole cn: defaults sudoOption: env_reset sudoOption: mail_badpass sudoOption: secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin dn: cn=%sudo,ou=sudo,dc=it213,dc=int objectClass: sudoRole cn: %sudo sudoUser: %sudo sudoHost: ALL sudoRunAsUser: ALL sudoRunAsGroup: ALL sudoCommand: ALL
EOF
- ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f /root/sudo_rules.ldif
Gruppenzuweisung
- ldapaddgroup sudo
- ldapaddusertogroup thomas sudo
- ldapaddusertogroup tina sudo
Tests und Kontrolle
Identität
- getent group it
- getent passwd thomas
- id tina
Sudo Check
- su - thomas
- sudo -l
- sudo whoami
Dienstverwaltung
- systemctl status slapd
- systemctl status sssd
- netstat -lntp | grep slapd

