dpkg-reconfigure slapd
vil la deg sette opp LDAP-databasen med flere detaljer:
falcot.com
».
dpkg-reconfigure slapd
rett etter den første installasjonen.
$
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: 2 # numEntries: 1
/etc/passwd
, /etc/group
, /etc/services
, /etc/hosts
, og så videre), konvertere disse dataene, og sette den inn i LDAP-databasen.
/etc/migrationtools/migrate_common.ph
redigeres; IGNORE_UID_BELOW
og IGNORE_GID_BELOW
-valgene må aktiveres (å avkommentere dem er nok), og DEFAULT_MAIL_DOMAIN
/DEFAULT_BASE
trenger oppdatering.
migrate_all_online.sh
-kommandoen, som følger:
#
cd /usr/share/migrationtools
#
PERL5LIB="${PERL5LIB}:/etc/migrationtools" LDAPADD="/usr/bin/ldapadd -c" ETC_ALIASES=/dev/null ./migrate_all_online.sh
migrate_all_online.sh
stiller noen få spørsmål om LDAP-databasen som dataene skal overføres til. Tabell 11.1 oppsummerer svarene fra Falcots brukereksempel.
Tabell 11.1. Svar på spørsmål forespurt av migrate_all_online.sh
-skriptet
Spørsmål | Svar |
---|---|
X.500 navnekontekst | dc=falcot,dc=com |
Vertsnavnet på LDAP-serveren | localhost |
Manager-DN | cn=admin,dc=falcot,dc=com |
Tilknytningsreferanser | det administrative passordet |
Lag DUAConfigProfile | nei |
PERL5LIB
variable. This is due to Debian bug report #982666.
/etc/aliases
file, since the standard schema as provided by Debian does not include the structures that this script uses to describe email aliases. Should we want to integrate this data into the directory, the /etc/ldap/schema/misc.schema
file should be added to the standard schema.
-c
-valget til ldapadd
-kommandoen; dette alternativet ber om at prosessen ikke stopper i tilfelle feil. Å bruke dette alternativet kreves fordi å konvertere /etc/services
ofte generer noen få feil som trygt kan ignoreres.
Tabell 11.2. Configuring the libnss-ldap package:
Spørsmål | Svar |
---|---|
LDAP server URI (Uniform Resource Identifier) | ldapi://ldap.falcot.com |
Øremerket navn for søkerbasen | dc=falcot,dc=com |
LDAP-versjon som skal brukes | 3 |
LDAP-konto for rot | cn=admin,dc=falcot,dc=com |
LDAP-passord for rotkonto | det administrative passordet |
Å tillate LDAP-adminkontoen oppføre seg som lokal rot? | ja |
Krever LDAP-databasen innlogging? | nei |
/etc/nsswitch.conf
må deretter endres, for å sette opp NSS til å bruke den nettopp installerte ldap
-modulen. Du kan bruke eksemplet fra /usr/share/doc/libnss-ldap/examples/nsswitch.ldap
eller redigere ditt eksisterende oppsett.
Eksempel 11.23. Filen /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
er vanligvis satt inn før de andre, og den vil derfor spørres først. Unntaket å merke seg er hosts
-tjenesten, siden LDAP-tjeneren krever å kontakte DNS først (for å løse ldap.falcot.com
). Uten dette unntaket, ville en forespørsel om vertsnavn prøve å spørre LDAP-tjeneren; dette ville utløse et navneoppslag for LDAP-tjeneren, og så videre i en uendelig sløyfe.
files
-modulen ignoreres), kan tjenester settes opp med følgende syntaks:
tjeneste: ldap [NOTFOUND=return] files
.
/etc/environment
og /etc/default/locale
) som vil tillate programmer å utføre de nødvendige godkjenninger mot LDAP-databasen.
Tabell 11.3. Oppsett av libpam-ldap
Spørsmål | Svar |
---|---|
Tillate LDAP-administrasjonskontoen å oppføre seg som lokal rot? | Ja. Dette tilllater å bruke den vanlige passwd -kommandoen for å endre passord lagret i LDAP-databasen. |
Krever LDAP-databasen innlogging? | nei |
LDAP account for root: | cn=admin,dc=falcot,dc=com |
LDAP administrative password: | LDAP-databasens administrative passord |
Local encryption algorithm to use for passwords: | crypt |
PAM-profiler å aktivere: | LDAP-identitetsbekreftelse er blandt de aktiverte profilene |
/etc/pam.d/common-auth
, /etc/pam.d/common-password
og /etc/pam.d/common-account
-filene. Denne mekanisme bruker det øremerkede pam-auth-update
-verktøyet (levert av libpam-runtime-pakken). Dette verktøyet kan også kjøres av administratoren dersom de ønsker å aktivere eller deaktivere PAM-moduler.
./easyrsa build-server-full ldap.falcot.com nopass
vil spørre deg om "felles navnet". Svaret på dette spørsmålet må være det fullstendige vertsnavnet for LDAP-tjeneren; i vårt tilfelle, ldap.falcot.com
.
pki/issued/ldap.falcot.com.crt
, og den tilhørende private nøkkelen lagres i pki/private/ldap.falcot.com.key
.
openldap
-brukerindentiteten:
#
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
#
mv pki/issued/ldap.falcot.com.crt /etc/ssl/certs/ldap.falcot.com.pem
#
chown root.root /etc/ssl/certs/ldap.falcot.com.pem
#
chmod 0644 /etc/ssl/certs/ldap.falcot.com.pem
slapd
må også få beskjed om å bruke disse nøklene/tastene til kryptering. LDAP-tjeneroppsettet styres dynamisk: oppsettet kan oppdateres med normale LDAP-operasjoner på cn=config
-objekthierarki, og tjeneroppdateringer på /etc/ldap/slapd.d
i sann tid for å gjøre oppsettet varig. ldapmodify
er dermed det riktige verktøyet for å oppdatere oppsettet:
Eksempel 11.24. Oppsett av slapd
for kryptering
#
cat >ssl.ldif <<END dn: cn=config changetype: modify add: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ssl/private/ldap.falcot.com.key - add: olcTLSCertificateFile olcTLSCertificateFile: /etc/ssl/certs/ldap.falcot.com.pem 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" #
systemctl restart slapd.service
#
ldapsearch -Y EXTERNAL -H ldapi:/// -b cn=config -s base | grep TLS
SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 olcTLSCertificateFile: /etc/ssl/certs/ldap.falcot.com.pem olcTLSCertificateKeyFile: /etc/ssl/certs/ldap.falcot.com.key
SLAPD_SERVICES
-variabelen i /etc/default/slapd
-filen. Vi skal gjøre det trygt, og helt deaktivere usikret LDAP.
Eksempel 11.25. Filen /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.d 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.
/usr/local/share/ca-certificates
and running update-ca-certificates
.
#
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
. Dette vil spare ganske mye skriving.
Eksempel 11.26. Filen /etc/ldap/ldap.conf
# # LDAP Defaults # # See ldap.conf(5) for details # This file should be world readable but not world writable. #BASE dc=example,dc=com #URI ldap://ldap.example.com ldap://ldap-provider.example.com:666 #SIZELIMIT 12 #TIMELIMIT 15 #DEREF never # TLS certificates (needed for GnuTLS) TLS_CACERT /etc/ssl/certs/ca-certificates.crt