dpkg-reconfigure slapd
will let you reconfigure the LDAP database with more details:
falcot.com
“.
dpkg-reconfigure slapd
unmittelbar nach der ersten Installierung ausführen.
$
ldapsearch -x -b dc=falcot,dc=com
# extended LDIF # # LDAPv3 # base <dc=falcot,dc=com> with scope subtree # filter: (objectclass=*) # requesting: ALL # # falcot.com dn: dc=falcot,dc=com objectClass: top objectClass: dcObject objectClass: organization o: Falcot Corp dc: falcot # admin, falcot.com dn: cn=admin,dc=falcot,dc=com objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator # search result search: 2 result: 0 Success # numResponses: 3 # numEntries: 2
/etc/passwd
, /etc/group
, /etc/services
, /etc/hosts
und so weiter) zu extrahieren, diese Daten zu konvertieren und sie in die LDAP-Datenbank einzuspeisen.
/etc/migrationtools/migrate_common.ph
editiert werden; die Optionen IGNORE_UID_BELOW
and IGNORE_GID_BELOW
müssen aktiviert werden (es genügt, das Kommentarzeichen zu entfernen) und die Variablen DEFAULT_MAIL_DOMAIN
/DEFAULT_BASE
müssen aktualisiert werden.
migrate_all_online.sh
folgendermaßen ausgeführt:
#
cd /usr/share/migrationtools
#
LDAPADD="/usr/bin/ldapadd -c" ETC_ALIASES=/dev/null ./migrate_all_online.sh
migrate_all_online.sh
stellt einige Fragen zur LDAP-Datenbank, auf die die Daten übertragen werden sollen. Tabelle 11.1 fasst die Antworten zusammen, die im Fallbeispiel Falcot gegeben wurden.
Tabelle 11.1. Antworten auf die vom Skript migrate_all_online.sh
gestellten Fragen
Frage | Antwort |
---|---|
X.500 Benennungskontext | dc=falcot,dc=com |
Hostname des LDAP-Servers | localhost |
Manager-DN | cn=admin,dc=falcot,dc=com |
Verbindungslegitimation | das Verwaltungspasswort |
Ein DUAConfigProfil anlegen | nein |
/etc/aliases
außerachtgelassen, da das von Debian bereitgestellte Standardschema nicht die Strukturen enthält, die dieses Skript zur Beschreibung der E-Mail-Aliasse verwendet. Falls wir diese Daten in das Verzeichnis integrieren möchten, müssen wir die Datei /etc/ldap/schema/misc.schema
zum Standardschema hinzufügen.
-c
des Befehls ldapadd
; diese Option bestimmt, dass der Verarbeitungsablauf im Falle eines Fehlers nicht abgebrochen wird. Die Verwendung dieser Option ist notwendig, da die Konvertierung der Datei /etc/services
häufig einige Fehler hervorruft, die ohne Gefahr ignoriert werden können.
Tabelle 11.2. Das Paket libnss-ldap konfigurieren
Frage | Antwort |
---|---|
Uniform Resource Identifier des LDAP-Servers | ldapi://ldap.falcot.com |
Kennzeichnender Name der Suchbasis | dc=falcot,dc=com |
Zu verwendende LDAP-Version | 3 |
LDAP-Administratorkonto | cn=admin,dc=falcot,dc=com |
Passwort des LDAP-Administratorkontos | das Verwaltungspasswort |
Allow LDAP admin account behave like local root? | yes |
Benötigt die LDAP-Datenbank eine Anmeldung? | nein |
/etc/nsswitch.conf
file then needs to be modified, so as to configure NSS to use the freshly-installed ldap
module. You can use the example provided in /usr/share/doc/libnss-ldap/examples/nsswitch.ldap or edit your existing configuration.
Beispiel 11.23. Die Datei /etc/nsswitch.conf
#ident $Id: nsswitch.ldap,v 2.4 2003/10/02 02:36:25 lukeh Exp $ # # An example file that could be copied over to /etc/nsswitch.conf; it # uses LDAP conjunction with files. # # "hosts:" and "services:" in this file are used only if the # /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports. # the following lines obviate the "+" entry in /etc/passwd and /etc/group. passwd: files ldap shadow: files ldap group: files ldap # consult DNS first, we will need it to resolve the LDAP host. (If we # can't resolve it, we're in infinite recursion, because libldap calls # gethostbyname(). Careful!) hosts: dns ldap # LDAP is nominally authoritative for the following maps. services: ldap [NOTFOUND=return] files networks: ldap [NOTFOUND=return] files protocols: ldap [NOTFOUND=return] files rpc: ldap [NOTFOUND=return] files ethers: ldap [NOTFOUND=return] files # no support for netmasks, bootparams, publickey yet. netmasks: files bootparams: files publickey: files automount: files # I'm pretty sure nsswitch.conf is consulted directly by sendmail, # here, so we can't do much here. Instead, use bbense's LDAP # rules ofr sendmail. aliases: files sendmailvars: files # Note: there is no support for netgroups on Solaris (yet) netgroup: ldap [NOTFOUND=return] files
ldap
-Modul wird normalerweise vor den anderen aufgenommen und wird daher zuerst abgefragt. Eine beachtenswerte Ausnahme stellt der hosts
-Dienst dar, da zunächst der DNS befragt werden muss (um ldap.falcot.com
aufzulösen), bevor mit dem LDAP-Server Verbindung aufgenommen werden kann. Ohne diese Ausnahme würde eine Anfrage nach einem Hostnamen an den LDAP-Server gerichtet; dies würde eine Namensauflösung für den LDAP-Server auslösen, und so weiter in einer unendlichen Schleife.
files
benutzten Dateien ignoriert werden sollen), können die Dienste mit der folgenden Syntax konfiguriert werden:
dienst: ldap [NOTFOUND=return] files
.
/etc/environment
und /etc/default/locale
), die es Anwendungen ermöglicht, die gegenüber der LDAP-Datenbank erforderlichen Authentifizierungen vorzunehmen.
Tabelle 11.3. Konfigurierung von libpam-ldap
Frage | Antwort |
---|---|
Dem LDAP-Administrationskonto erlauben, sich wie lokales Root zu verhalten? | Ja. Dies ermöglicht es, den normalen passwd -Befehl zur Änderung von Passwörtern zu verwenden, die in der LDAP-Datenbank gespeichert sind. |
Erfordert die LDAP-Datenbank eine Anmeldung? | nein |
LDAP-Administratorkonto | cn=admin,dc=falcot,dc=com |
Passwort des LDAP-Administratorkontos | das Verwaltungspasswort der LDAP-Datenbank |
Lokaler Verschlüsselungsalgorithmus für Passwörter | crypt |
/etc/pam.d/common-auth
, /etc/pam.d/common-password
und /etc/pam.d/common-account
festgelegt ist, automatisch angepasst. Dieser Vorgang verwendet das spezielle Hilfsprogramm pam-auth-update
(vom Paket libpam-runtime bereitgestellt). Dieses Programm kann auch vom Administrator eingesetzt werden, falls er PAM-Module aktivieren oder deaktivieren möchte.
./easyrsa build-server-full ldap.falcot.com nopass
will ask you about the “common name”. The answer to that question must be the fully-qualified hostname for the LDAP server; in our case, ldap.falcot.com
.
pki/issued/ldap.falcot.com.crt
file; the corresponding private key is stored in pki/private/ldap.falcot.com.key
.
openldap
läuft:
#
adduser openldap ssl-cert
Adding user `openldap' to group `ssl-cert' ... Adding user openldap to group ssl-cert Done. #
mv pki/private/ldap.falcot.com.key /etc/ssl/private/ldap.falcot.com.key
#
chown root:ssl-cert /etc/ssl/private/ldap.falcot.com.key
#
chmod 0640 /etc/ssl/private/ldap.falcot.com.key
#
./eassyrsa gen-dh
Note: using Easy-RSA configuration from: ./vars Using SSL: openssl OpenSSL 1.1.1c 28 May 2019 Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ........................................................+..........................................................................+...............................................................................+............ [...] DH parameters of size 2048 created at /home/roland/pki/dh.pem #
mv pki/dh.pem /etc/ssl/certs/ldap.falcot.com.pem
slapd
muss ebenfalls dazu gebracht werden, diese Schlüssel für die Verschlüsselung zu verwenden. Die Konfiguration des LDAP-Servers wird dynamisch verwaltet: die Konfiguration kann mit normalen LDAP-Operationen innerhalb der Objekt-Hierarchie cn=config
aktualisiert werden und der Server aktualisiert /etc/ldap/slapd.d
in Echtzeit um die Konfiguration durchgängig zu halten. Ldapmodify
ist also das geeignete Werkzeug um die Konfiguration zu aktualisieren:
Beispiel 11.24. slapd
für eine Verschlüsselung konfigurieren
#
cat >ssl.ldif <<END dn: cn=config changetype: modify add: olcTLSCertificateFile olcTLSCertificateFile: /etc/ssl/certs/ldap.falcot.com.pem - add: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ssl/private/ldap.falcot.com.key - END
#
ldapmodify -Y EXTERNAL -H ldapi:/// -f ssl.ldif
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 modifying entry "cn=config"
SLAPD_SERVICES
in der Datei /etc/default/slapd
zu ändern. Wir gehen dabei auf Nummer Sicher und deaktivieren nicht abgesichertes LDAP vollständig.
Beispiel 11.25. Die Datei /etc/default/slapd
# Default location of the slapd.conf file or slapd.d cn=config directory. If # empty, use the compiled-in default (/etc/ldap/slapd.d with a fallback to # /etc/ldap/slapd.conf). SLAPD_CONF= # System account to run the slapd server under. If empty the server # will run as root. SLAPD_USER="openldap" # System group to run the slapd server under. If empty the server will # run in the primary group of its user. SLAPD_GROUP="openldap" # Path to the pid file of the slapd server. If not set the init.d script # will try to figure it out from $SLAPD_CONF (/etc/ldap/slapd.conf by # default) SLAPD_PIDFILE= # slapd normally serves ldap only on all TCP-ports 389. slapd can also # service requests on TCP-port 636 (ldaps) and requests via unix # sockets. # Example usage: # SLAPD_SERVICES="ldap://127.0.0.1:389/ ldaps:/// ldapi:///" SLAPD_SERVICES="ldaps:/// ldapi:///" # If SLAPD_NO_START is set, the init script will not start or restart # slapd (but stop will still work). Uncomment this if you are # starting slapd via some other means or if you don't want slapd normally # started at boot. #SLAPD_NO_START=1 # If SLAPD_SENTINEL_FILE is set to path to a file and that file exists, # the init script will not start or restart slapd (but stop will still # work). Use this for temporarily disabling startup of slapd (when doing # maintenance, for example, or through a configuration management system) # when you don't want to edit a configuration file. SLAPD_SENTINEL_FILE=/etc/ldap/noslapd # For Kerberos authentication (via SASL), slapd by default uses the system # keytab file (/etc/krb5.keytab). To use a different keytab file, # uncomment this line and change the path. #export KRB5_KTNAME=/etc/krb5.keytab # Additional options to pass to slapd SLAPD_OPTIONS=""
ldaps://
URI zu nutzen zu können.
/usr/local/share/ca-certificates
einträgt und dann update-ca-certificates
startet.
#
cp pki/ca.crt /usr/local/share/ca-certificates/falcot.crt
#
update-ca-certificates
Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d.... Adding debian:falcot.pem done. done.
/etc/ldap/ldap.conf
geändert werden. Das erspart einiges an Tipparbeit.
Beispiel 11.26. Die Datei /etc/ldap/ldap.conf
# # LDAP Defaults # # See ldap.conf(5) for details # This file should be world readable but not world writable. BASE dc=falcot,dc=com URI ldaps://ldap.falcot.com #SIZELIMIT 12 #TIMELIMIT 15 #DEREF never # TLS certificates (needed for GnuTLS) TLS_CACERT /etc/ssl/certs/ca-certificates.crt