Zentrale Benutzerverwaltung mit OpenLDAP und SSS: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 1: | Zeile 1: | ||
| − | =Installation= | + | = Installation = |
;passwort nach wahl festlegen | ;passwort nach wahl festlegen | ||
| − | *apt install | + | * apt install slapd ldap-utils |
;slapd: OpenLDAP Standalone Server | ;slapd: OpenLDAP Standalone Server | ||
;ldap-utils: Utilities zum Zugriff auf den LDAP Server | ;ldap-utils: Utilities zum Zugriff auf den LDAP Server | ||
| − | =Grundkonfiguration= | + | = Grundkonfiguration = |
[[Datei:Ldap-61.png]] | [[Datei:Ldap-61.png]] | ||
[[Datei:Ldap-62.png]] | [[Datei:Ldap-62.png]] | ||
| − | =Weitere Konfiguration= | + | |
| − | *dpkg-reconfigure -p low slapd | + | = Weitere Konfiguration = |
| + | * dpkg-reconfigure -p low slapd | ||
[[Datei:Ldap-63.png]] | [[Datei:Ldap-63.png]] | ||
| Zeile 26: | Zeile 27: | ||
[[Datei:Ldap-66.png]] | [[Datei:Ldap-66.png]] | ||
| − | =Konfiguration des Clients= | + | |
| − | ==ldap.conf== | + | = Konfiguration des Clients = |
| − | *cat /etc/ldap/ldap.conf | + | == ldap.conf == |
| − | base dc= | + | * cat /etc/ldap/ldap.conf |
| − | uri ldap://server. | + | base dc=it213, dc=int |
| + | uri ldap://server.it213.int | ||
ldap_version 3 | ldap_version 3 | ||
| − | rootbinddn cn=admin, dc= | + | rootbinddn cn=admin, dc=it213, dc=int |
pam_password md5 | pam_password md5 | ||
| − | ==Passwort für den Adminzugang eintragen== | + | |
| − | *echo 123Start$ > /etc/ldap.secret | + | == Passwort für den Adminzugang eintragen == |
| − | =Kontrolle= | + | * echo 123Start$ > /etc/ldap.secret |
| − | ==Stimmt der base dn | + | |
| − | *ldapsearch -x -LLL | + | = Kontrolle = |
| − | dn: dc= | + | == Stimmt der base dn == |
| + | * ldapsearch -x -LLL | ||
| + | dn: dc=it213,dc=int | ||
objectClass: top | objectClass: top | ||
objectClass: dcObject | objectClass: dcObject | ||
objectClass: organization | objectClass: organization | ||
| − | o: | + | o: it213 |
| − | dc: | + | dc: it213 |
| − | =Grundstruktur= | + | |
| − | {{#drawio: | + | = Grundstruktur = |
| − | ==Erstellen== | + | {{#drawio:it213-ldap}} |
| − | *cat /root/struktur.ldif | + | |
| − | + | == Erstellen == | |
| − | dn: ou=users,dc= | + | * cat /root/struktur.ldif |
| − | objectClass: organizationalUnit | + | dn: ou=users,dc=it213,dc=int |
| − | ou: users | + | 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 | ||
| − | + | == Anlegen == | |
| − | + | * ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f struktur.ldif | |
| − | ou | + | adding new entry "ou=users,dc=it213,dc=int" |
| + | adding new entry "ou=groups,dc=it213,dc=int" | ||
| + | adding new entry "ou=hosts,dc=it213,dc=int" | ||
| − | + | = 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" | ||
| + | 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" | ||
| + | LOGTOSYSLOG="no" | ||
| + | SYSLOGFACILITY="local4" | ||
| + | SYSLOGLEVEL="info" | ||
| + | LDAPSEARCHBIN="/usr/bin/ldapsearch" | ||
| + | LDAPADDBIN="/usr/bin/ldapadd" | ||
| + | LDAPDELETEBIN="/usr/bin/ldapdelete" | ||
| + | LDAPMODIFYBIN="/usr/bin/ldapmodify" | ||
| + | LDAPMODRDNBIN="/usr/bin/ldapmodrdn" | ||
| + | LDAPPASSWDBIN="/usr/bin/ldappasswd" | ||
| + | LDAPSEARCHOPTS="-o ldif-wrap=no" | ||
| − | + | === Password Datei === | |
| + | * echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd | ||
| − | + | == Managment == | |
| + | === Struktur === | ||
| + | {{#drawio:it213-2}} | ||
| − | = | + | === Gruppen anlegen === |
| − | == | + | * ldapaddgroup it |
| − | * | ||
| − | == | + | === Benutzer anlegen === |
| − | + | * ldapadduser thomas it | |
| − | * | + | * ldapadduser tina it |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | === | + | === Passwörter setzen === |
| − | * | + | * ldapsetpasswd thomas |
| − | + | * ldapsetpasswd tina | |
| − | |||
| − | |||
| − | == | + | = nsswitch und pam anbinden = |
| − | + | * [[Zusammenspiel von PAM und NSS]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | * | ||
| − | + | == Installation == | |
| − | + | * env DEBIAN_FRONTEND=noninteractive apt install -yqq libnss-ldap libpam-ldap nslcd | |
| − | ==Installation== | ||
| − | *env DEBIAN_FRONTEND=noninteractive apt install -yqq | ||
;Wir konfigurieren von Hand | ;Wir konfigurieren von Hand | ||
| − | ==ldap.conf== | + | == ldap.conf == |
| − | *cat /etc/ldap/ldap.conf | + | * cat /etc/ldap/ldap.conf |
| − | base dc= | + | base dc=it213, dc=int |
| − | uri ldap://server. | + | uri ldap://server.it213.int |
ldap_version 3 | ldap_version 3 | ||
| − | rootbinddn cn=admin, dc= | + | rootbinddn cn=admin, dc=it213, dc=int |
pam_password md5 | pam_password md5 | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Passwort für den Adminzugang eintragen == | |
| − | + | * echo 123Start$ > /etc/ldap.secret | |
| − | |||
| − | + | == Wir benutzen nur eine Konfigurationdatei == | |
| − | + | * ln -fs /etc/ldap/ldap.conf /etc/libnss-ldap.conf | |
| + | * ln -fs /etc/ldap/ldap.conf /etc/pam_ldap.conf | ||
| − | + | == nslcd.conf == | |
| − | base dc= | + | * cat /etc/nslcd.conf |
| − | + | uid nslcd | |
| + | gid nslcd | ||
| + | uri ldap://ldap.it213.int | ||
| + | base dc=it213,dc=int | ||
| − | ==Nsswitch anpassen== | + | == Nsswitch anpassen == |
| − | *cat /etc/nsswitch.conf | + | * cat /etc/nsswitch.conf |
passwd: files ldap | passwd: files ldap | ||
group: files ldap | group: files ldap | ||
shadow: files ldap | shadow: files ldap | ||
| − | ==PAM anpassen== | + | == PAM anpassen == |
| − | + | Falls ein Home Verzeichnis gewünscht ist, muss folgende Datei bearbeitet werden: | |
| − | + | * '''nano /etc/pam.d/common-session''' | |
| − | + | session required pam_mkhomedir.so skel=/etc/skel umask=0022 | |
| − | |||
| − | |||
| − | |||
| − | session required pam_mkhomedir.so skel=/etc/skel umask=0022 | ||
| − | |||
| − | ==Reboot== | + | == Reboot == |
!!!Reboot!!! | !!!Reboot!!! | ||
| − | =Tests= | + | = Tests = |
| − | *getent group it | + | * getent group it |
it:*:10000: | it:*:10000: | ||
| − | *getent passwd thomas | + | * getent passwd thomas |
thomas:*:10000:10000:thomas:/home/thomas:/bin/bash | thomas:*:10000:10000:thomas:/home/thomas:/bin/bash | ||
| − | + | * su - tina | |
| − | |||
| − | *su - tina | ||
tina@server:~$ | tina@server:~$ | ||
| − | == | + | == Dienstverwaltung == |
| − | + | * systemctl start slapd | |
| − | + | * systemctl stop slapd | |
| − | + | * systemctl restart slapd | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | == | + | == Portprüfung == |
| + | * netstat -lntp | grep slapd | ||
| + | tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 499/slapd | ||
| + | = Sudo = | ||
Sudo Gruppe auf dem ldap Server anlegen: | Sudo Gruppe auf dem ldap Server anlegen: | ||
| − | + | * ldapaddgroup sudo | |
| + | * ldapaddusertogroup thomas sudo | ||
| + | * ldapaddusertogroup tina sudo | ||
| − | + | Pakete installieren: | |
| − | |||
| − | |||
| − | |||
* apt install sudo-ldap | * apt install sudo-ldap | ||
| − | + | Konfiguration: | |
| − | |||
* visudo -f /etc/sudoers.d/ldap-sudoers | * visudo -f /etc/sudoers.d/ldap-sudoers | ||
| − | |||
%sudo ALL=(ALL:ALL) ALL | %sudo ALL=(ALL:ALL) ALL | ||
* vim /etc/sudo-ldap.conf | * vim /etc/sudo-ldap.conf | ||
| − | sudoers_base ou=sudo,dc= | + | sudoers_base ou=sudo,dc=it213,dc=int |
Testen: | Testen: | ||
| − | + | * su - thomas | |
| − | + | * sudo -l | |
| − | + | * sudo whoami | |
Version vom 1. April 2026, 17:27 Uhr
Installation
- passwort nach wahl festlegen
- apt install slapd ldap-utils
- slapd
- OpenLDAP Standalone Server
- ldap-utils
- Utilities zum Zugriff auf den LDAP Server
Grundkonfiguration
Weitere Konfiguration
- dpkg-reconfigure -p low slapd
Konfiguration des Clients
ldap.conf
- cat /etc/ldap/ldap.conf
base dc=it213, dc=int uri ldap://server.it213.int ldap_version 3 rootbinddn cn=admin, dc=it213, dc=int pam_password md5
Passwort für den Adminzugang eintragen
- echo 123Start$ > /etc/ldap.secret
Kontrolle
Stimmt der base dn
- ldapsearch -x -LLL
dn: dc=it213,dc=int objectClass: top objectClass: dcObject objectClass: organization o: it213 dc: it213
Grundstruktur
Erstellen
- cat /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
Anlegen
- ldapadd -xD cn=admin,dc=it213,dc=int -w 123Start$ -f struktur.ldif
adding new entry "ou=users,dc=it213,dc=int" adding new entry "ou=groups,dc=it213,dc=int" adding new entry "ou=hosts,dc=it213,dc=int"
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" 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" LOGTOSYSLOG="no" SYSLOGFACILITY="local4" SYSLOGLEVEL="info" LDAPSEARCHBIN="/usr/bin/ldapsearch" LDAPADDBIN="/usr/bin/ldapadd" LDAPDELETEBIN="/usr/bin/ldapdelete" LDAPMODIFYBIN="/usr/bin/ldapmodify" LDAPMODRDNBIN="/usr/bin/ldapmodrdn" LDAPPASSWDBIN="/usr/bin/ldappasswd" LDAPSEARCHOPTS="-o ldif-wrap=no"
Password Datei
- echo -n "123Start$" > /etc/ldapscripts/ldapscripts.passwd
Managment
Struktur
Gruppen anlegen
- ldapaddgroup it
Benutzer anlegen
- ldapadduser thomas it
- ldapadduser tina it
Passwörter setzen
- ldapsetpasswd thomas
- ldapsetpasswd tina
nsswitch und pam anbinden
Installation
- env DEBIAN_FRONTEND=noninteractive apt install -yqq libnss-ldap libpam-ldap nslcd
- Wir konfigurieren von Hand
ldap.conf
- cat /etc/ldap/ldap.conf
base dc=it213, dc=int uri ldap://server.it213.int ldap_version 3 rootbinddn cn=admin, dc=it213, dc=int pam_password md5
Passwort für den Adminzugang eintragen
- echo 123Start$ > /etc/ldap.secret
Wir benutzen nur eine Konfigurationdatei
- ln -fs /etc/ldap/ldap.conf /etc/libnss-ldap.conf
- ln -fs /etc/ldap/ldap.conf /etc/pam_ldap.conf
nslcd.conf
- cat /etc/nslcd.conf
uid nslcd gid nslcd uri ldap://ldap.it213.int base dc=it213,dc=int
Nsswitch anpassen
- cat /etc/nsswitch.conf
passwd: files ldap group: files ldap shadow: files ldap
PAM anpassen
Falls ein Home Verzeichnis gewünscht ist, muss folgende Datei bearbeitet werden:
- nano /etc/pam.d/common-session
session required pam_mkhomedir.so skel=/etc/skel umask=0022
Reboot
!!!Reboot!!!
Tests
- getent group it
it:*:10000:
- getent passwd thomas
thomas:*:10000:10000:thomas:/home/thomas:/bin/bash
- su - tina
tina@server:~$
Dienstverwaltung
- systemctl start slapd
- systemctl stop slapd
- systemctl restart slapd
Portprüfung
- netstat -lntp | grep slapd
tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 499/slapd
Sudo
Sudo Gruppe auf dem ldap Server anlegen:
- ldapaddgroup sudo
- ldapaddusertogroup thomas sudo
- ldapaddusertogroup tina sudo
Pakete installieren:
- apt install sudo-ldap
Konfiguration:
- visudo -f /etc/sudoers.d/ldap-sudoers
%sudo ALL=(ALL:ALL) ALL
- vim /etc/sudo-ldap.conf
sudoers_base ou=sudo,dc=it213,dc=int
Testen:
- su - thomas
- sudo -l
- sudo whoami








