LDAP Client SSSD - Netzwerk und Serveradministration: Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „= OpenLDAP mit SSSD Client-Konfiguration = == Inhaltsverzeichnis == # Installation (Server) # Grundkonfiguration (Server) # Weitere Konfiguration (Server) #…“) |
|||
| Zeile 1: | Zeile 1: | ||
= OpenLDAP mit SSSD Client-Konfiguration = | = OpenLDAP mit SSSD Client-Konfiguration = | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
== Installation (Server) == | == Installation (Server) == | ||
Aktuelle Version vom 15. Oktober 2025, 12:56 Uhr
OpenLDAP mit SSSD Client-Konfiguration
Installation (Server)
Passwort nach Wahl festlegen:
apt install slapd ldap-utils
- slapd
- OpenLDAP Standalone Server
- ldap-utils
- Utilities zum Zugriff auf den LDAP Server
Grundkonfiguration (Server)
Während der Installation Domain-Name angeben: it113.int
Weitere Konfiguration (Server)
dpkg-reconfigure -p low slapd
Folgende Einstellungen vornehmen:
- DNS domain name:
it113.int - Organization name:
it113 - Administrator password: (Passwort festlegen)
- Database backend: MDB
- Remove database when slapd is purged: No
- Move old database: Yes
Konfiguration des Clients
ldap.conf
cat /etc/ldap/ldap.conf
base dc=it113,dc=int
uri ldap://server.it113.int
ldap_version 3
rootbinddn cn=admin,dc=it113,dc=int
pam_password md5
Passwort für den Adminzugang eintragen
echo 123Start$ > /etc/ldap.secret chmod 600 /etc/ldap.secret
Kontrolle
Stimmt der base dn?
ldapsearch -x -LLL
Erwartete Ausgabe:
dn: dc=it113,dc=int
objectClass: top
objectClass: dcObject
objectClass: organization
o: it113
dc: it113
Grundstruktur
Erstellen
cat /root/struktur.ldif
dn: ou=users,dc=it113,dc=int
objectClass: organizationalUnit
ou: users
dn: ou=groups,dc=it113,dc=int
objectClass: organizationalUnit
ou: groups
dn: ou=hosts,dc=it113,dc=int
objectClass: organizationalUnit
ou: hostsAnlegen
ldapadd -xD cn=admin,dc=it113,dc=int -w 123Start$ -f /root/struktur.ldif
Erwartete Ausgabe:
adding new entry "ou=users,dc=it113,dc=int"
adding new entry "ou=groups,dc=it113,dc=int"
adding new entry "ou=hosts,dc=it113,dc=int"
Ldapscripts
Installation
apt install ldapscripts
Konfiguration
Hauptkonfiguration
vim /etc/ldapscripts/ldapscripts.conf
SERVER="ldap://ldap.it113.int"
SUFFIX="dc=it113,dc=int"
GSUFFIX="ou=groups"
USUFFIX="ou=users"
MSUFFIX="ou=hosts"
BINDDN="cn=admin,dc=it113,dc=int"
USHELL="/bin/bash"
UHOMES="/home/%u"
CREATEHOMES="yes"
HOMESKEL="/etc/skel"
BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd"
GIDSTART="10000"
UIDSTART="10000"
MIDSTART="20000"
GCLASS="posixGroup"
PASSWORDGEN="pwgen"
RECORDPASSWORDS="no"
PASSWORDFILE="/var/log/ldapscripts_passwd.log"
LOGTOFILE="yes"
LOGFILE="/var/log/ldapscripts.log"
Password Datei
echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd chmod 600 /etc/ldapscripts/ldapscripts.passwd
Management
Gruppen anlegen
ldapaddgroup it
Benutzer anlegen
ldapadduser thomas it ldapadduser tina it
Passwörter setzen
ldapsetpasswd thomas ldapsetpasswd tina
DNS-Konfiguration (WICHTIG!)
Für SSSD Service Discovery werden DNS SRV Records benötigt.
DNS SRV Records anlegen
Im DNS-Server (z.B. BIND) folgende Einträge hinzufügen:
; LDAP Server A-Record
ldap.it113.int. IN A 192.168.113.10
server.it113.int. IN A 192.168.113.10
; SRV Records für LDAP Service Discovery
_ldap._tcp.it113.int. IN SRV 0 5 389 ldap.it113.int.SRV Record Parameter:
0= Priority (0 = höchste Priorität)5= Weight (für Load Balancing)389= LDAP Portldap.it113.int.= Hostname des LDAP-Servers
DNS testen
# A-Record testen dig ldap.it113.int A # SRV-Record testen (muss funktionieren!) dig _ldap._tcp.it113.int SRV
Erwartete SRV-Ausgabe:
_ldap._tcp.it113.int. 86400 IN SRV 0 5 389 ldap.it113.int.
SSSD Client-Konfiguration
SSSD (System Security Services Daemon) ersetzt die alte Konfiguration mit libnss-ldap und libpam-ldap.
Installation
apt install sssd-ldap ldap-utils
ldap.conf (Client)
cat /etc/ldap/ldap.conf
base dc=it113,dc=int
uri ldap://server.it113.int
ldap_version 3
SSSD Konfiguration
vim /etc/sssd/sssd.conf
[sssd]
config_file_version = 2
services = nss, pam
domains = it113.int
[domain/it113.int]
id_provider = ldap
auth_provider = ldap
chpass_provider = ldap
# DNS Service Discovery nutzen (benötigt SRV Records!)
ldap_uri = _srv_
dns_discovery_domain = it113.int
ldap_search_base = dc=it113,dc=int
ldap_default_bind_dn = cn=admin,dc=it113,dc=int
ldap_default_authtok_type = password
ldap_default_authtok = 123Start$
# TLS komplett deaktivieren (für Testumgebungen)
ldap_id_use_start_tls = false
ldap_auth_disable_tls_never_use_in_production = true
ldap_tls_reqcert = never
cache_credentials = true
enumerate = true
[nss]
filter_users = root,daemon,bin,sys,sync,games,man,lp,mail,news,uucp,proxy,www-data,backup,list,irc,gnats,nobody,systemd-network,systemd-resolve,messagebus,_apt,uuidd,nslcd
filter_groups = root,daemon,bin,sys,adm,tty,disk,lp,mail,news,uucp,man,proxy,kmem,dialout,fax,voice,cdrom,floppy,tape,sudo,audio,dip,www-data,backup,operator,list,irc,src,gnats,shadow,utmp,video,sasl,plugdev,staff,games,users,nogroup,systemd-journal,systemd-network,systemd-resolve,input,kvm,render,crontab,netdev,messagebus,_apt,uuidd,ssh,nslcd
[pam]
offline_credentials_expiration = 2
Alternative ohne DNS SRV Records:
Falls die DNS SRV Records nicht funktionieren, kann man auch direkt den Server angeben:
[domain/it113.int]
id_provider = ldap
auth_provider = ldap
chpass_provider = ldap
# Direkte URI statt DNS Discovery
ldap_uri = ldap://ldap.it113.int:389
ldap_search_base = dc=it113,dc=int
# TLS deaktivieren
ldap_id_use_start_tls = false
ldap_auth_disable_tls_never_use_in_production = true
ldap_tls_reqcert = never
# ... rest wie oben
Berechtigungen setzen
chmod 600 /etc/sssd/sssd.conf
SSSD Service aktivieren und starten
systemctl enable sssd systemctl start sssd
NSS-Konfiguration anpassen
vim /etc/nsswitch.conf
passwd: files sss
group: files sss
shadow: files sss
PAM-Konfiguration
PAM muss für SSSD-Authentifizierung konfiguriert werden.
Automatische Konfiguration (empfohlen)
pam-auth-update
Aktiviere folgende Optionen:
- SSS authentication (für SSSD)
- Create home directory on login (für automatische Home-Verzeichnisse)
Manuelle PAM-Konfiguration
Falls die automatische Konfiguration nicht funktioniert:
1. common-auth bearbeiten:
vim /etc/pam.d/common-auth
Nach der pam_unix.so Zeile hinzufügen:
auth sufficient pam_sss.so use_first_pass
2. common-account bearbeiten:
vim /etc/pam.d/common-account
account sufficient pam_sss.so
3. common-password bearbeiten:
vim /etc/pam.d/common-password
password sufficient pam_sss.so use_authtok
4. common-session bearbeiten:
vim /etc/pam.d/common-session
session optional pam_sss.so
session required pam_mkhomedir.so skel=/etc/skel umask=0077
Die pam_mkhomedir.so Zeile ist sehr wichtig - sie erstellt automatisch Home-Verzeichnisse beim ersten Login!
PAM-Konfiguration prüfen
# Prüfen ob pam_sss eingebunden ist grep -r "pam_sss" /etc/pam.d/ # Prüfen ob pam_mkhomedir eingebunden ist grep -r "pam_mkhomedir" /etc/pam.d/
Tests
SSSD Cache leeren (bei Problemen)
systemctl stop sssd rm -rf /var/lib/sss/db/* systemctl start sssd
Benutzer und Gruppen abfragen
getent group it
Erwartete Ausgabe:
it:*:10000:
getent passwd thomas
Erwartete Ausgabe:
thomas:*:10000:10000:thomas:/home/thomas:/bin/bash
getent passwd tina
Erwartete Ausgabe:
tina:*:10001:10000:tina:/home/tina:/bin/bash
Login und Home-Verzeichnis testen
# Login als LDAP-User su - thomas # Prüfen ob Home-Verzeichnis erstellt wurde pwd # Sollte /home/thomas zeigen ls -la # Sollte Dateien aus /etc/skel zeigen (.bashrc, .profile, etc.)
Authentifizierung testen
# Passwort-Login testen su - tina # Auth-Log bei Problemen prüfen tail -f /var/log/auth.log
SSSD Status prüfen
systemctl status sssd # Domain-Status sssctl domain-status it113.int # SSSD Logs bei Problemen journalctl -u sssd -n 100 tail -f /var/log/sssd/sssd_it113.int.log
Häufige Probleme
Problem: "Could not start TLS encryption"
Lösung: In /etc/sssd/sssd.conf hinzufügen:
ldap_auth_disable_tls_never_use_in_production = true
Problem: "No such file or directory" beim Login
Lösung: Home-Verzeichnisse werden nicht erstellt. Prüfe ob pam_mkhomedir aktiv ist:
grep pam_mkhomedir /etc/pam.d/common-session
Problem: "Authentication failure"
Lösung: PAM-Module nicht richtig konfiguriert. Prüfe:
grep pam_sss /etc/pam.d/common-auth grep pam_sss /etc/pam.d/common-account
LDAP Server Management
Starten des slapd
systemctl start slapd
Stoppen des slapd
systemctl stop slapd
Neustarten des slapd
systemctl restart slapd
Auf welchem Port lauscht der slapd
netstat -lntp | grep slapd
Erwartete Ausgabe:
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 499/slapd
Sudo-Konfiguration
Problem: Namenskonflikt mit lokaler sudo-Gruppe
Die lokale sudo-Gruppe (GID 27) kollidiert mit einer LDAP-Gruppe gleichen Namens. Daher verwenden wir einen anderen Gruppennamen für LDAP.
Admin-Gruppe auf dem LDAP Server anlegen
# Gruppe "admins" statt "sudo" anlegen (vermeidet Konflikt) ldapaddgroup admins # Benutzer zur Admin-Gruppe hinzufügen ldapaddusertogroup thomas admins ldapaddusertogroup tina admins
Gruppe prüfen
# Auf dem Client prüfen ob die Gruppe sichtbar ist getent group admins
Erwartete Ausgabe:
admins:*:10001:thomas,tina
Sudoers konfigurieren (Client)
visudo -f /etc/sudoers.d/ldap-admins
# LDAP Admins Gruppe
%admins ALL=(ALL:ALL) ALL
Berechtigungen setzen
chmod 0440 /etc/sudoers.d/ldap-admins
Testen
# Als LDAP-User einloggen su - thomas # Gruppenmitgliedschaft prüfen id # Sollte "groups=10000(it),10001(admins)" zeigen groups # Sollte "it admins" zeigen # Sudo testen sudo whoami # Sollte "root" ausgeben sudo -l # Sollte die sudo-Rechte anzeigen
Troubleshooting
Problem: Gruppe wird nicht angezeigt
# SSSD Cache leeren systemctl stop sssd rm -rf /var/lib/sss/db/* systemctl start sssd # Neu einloggen su - thomas id
Problem: "User is not in sudoers file"
Prüfe ob die Gruppe korrekt angelegt ist:
# Auf dem LDAP-Server ldapsearch -x -b "ou=groups,dc=it113,dc=int" "(cn=admins)" # Auf dem Client getent group admins
Troubleshooting
SSSD Debug-Modus aktivieren
vim /etc/sssd/sssd.conf
In der [domain/it113.int] Sektion hinzufügen:
debug_level = 9
Dann SSSD neu starten und Logs prüfen:
systemctl restart sssd tail -f /var/log/sssd/sssd_it113.int.log
LDAP-Verbindung manuell testen
ldapsearch -x -H ldap://server.it113.int -b dc=it113,dc=int -D cn=admin,dc=it113,dc=int -W
Vorteile von SSSD gegenüber NSS/PAM-LDAP
- Caching: Offline-Login möglich
- Performance: Bessere Performance durch intelligentes Caching
- Moderne Architektur: Aktiv entwickelt und gewartet
- Flexibilität: Unterstützt mehrere Identity Provider
- Besseres Debugging: Umfangreiche Logging-Optionen