dpkg-reconfigure slapd
will let you reconfigure the LDAP database with more details:
falcot.com
».
dpkg-reconfigure slapd
inmediatamente después de instalarlo por primera vez.
$
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
, etc.), convetir estos datos y agregarlos en la base de datos LDAP.
/etc/migrationtools/migrate_common.ph
; debe activar las opciones IGNORE_UID_BELOW
y IGNORE_GID_BELOW
(descomentarlas es suficiente) y debe actualizar DEFAULT_MAIL_DOMAIN
/DEFAULT_BASE
.
migrate_all_online.sh
, como sigue:
#
cd /usr/share/migrationtools
#
LDAPADD="/usr/bin/ldapadd -c" ETC_ALIASES=/dev/null ./migrate_all_online.sh
migrate_all_online.sh
realizará unas pocas preguntas sobre la base de datos LDAP a la que migrará los datos. La Tabla 11.1 resume las respuestas dadas en el caso de uso de Falcot.
Tabla 11.1. Respuestas a las preguntas del script migrate_all_online.sh
Pregunta | Respuesta |
---|---|
Contexto de nombre X.500 | dc=falcot,dc=com |
Nombre del servidor LDAP | localhost |
Administrador del DN | cn=admin,dc=falcot,dc=com |
Credenciales Bind | la contraseña de administración |
Crear DUAConfigProfile | no |
/etc/aliases
, ya que el esquema estándar provisto por Debian no incluye la estructura que utiliza este script para describir alias de correo. Si quisiéramos integrar estos datos en el directorio, debe agregar el archivo /etc/ldap/schema/misc.schema
al esquema estándar.
ldapadd
tiene una opción -c
; esta opción solicita que no se detenga el proceso en caso de errores. Es necesario utilizar esta opción debido a que la conversión del archivo /etc/services
genera unos pocos errores que puede ignorar sin problemas.
Tabla 11.2. Configuración del paquete lbnss-ldap
Pregunta | Respuesta |
---|---|
Identificar de recurso uniforme (URI) del servidor LDAP | ldapi://ldap.falcot.com |
Nombre distinguido de la base de búsqueda | dc=falcot,dc=com |
Versión LDAP a utilizar | 3 |
cuenta LDAP para root | cn=admin,dc=falcot,dc=com |
contraseña de la cuenta root de LDAP | la contraseña de administración |
Allow LDAP admin account behave like local root? | yes |
¿La base de datos LDAP requiere inicio de sesión? | no |
/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.
Ejemplo 11.23. El archivo /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
antes que los demás para que, de esa forma, sea consultado primero. La excepción notable es el servicio hosts
ya que para contactar el servidor LDAP necesita una consulta de DNS primero (para resolver ldap.falcot.com
). Sin esta excepción, una consulta de nombres intentaría consultar al servidor LDAP; esto dispararía una resolución de nombres para el servidor LDAP, y así sucesivamente en un ciclo infinito.
files
), puede configurar los servicios con la siguiente sintaxis:
servicio: ldap [NOTFOUND=return] files
.
/etc/environment
y /etc/default/locale
) que permitirá a las aplicaciones realizar las autenticaciones necesarias contra la base de datos LDAP.
Tabla 11.3. Configuración de libpam-ldap
Pregunta | Respuesta |
---|---|
¿Permitir a la cuenta de administración LDAP comportarse como root local? | Sí. Esto permite utilizar el programa passwd típico para modificar las contraseñas almacenadas en la base de datos LDAP. |
¿La base de datos LDAP requiere inicio de sesión? | no |
cuenta LDAP para root | cn=admin,dc=falcot,dc=com |
contraseña de la cuenta root de LDAP | la contraseña de administración de la base de datos LDAP |
Algoritmo local de cifrado para las contraseñas | crypt |
/etc/pam.d/common-auth
, /etc/pam.d/common-password
y /etc/pam.d/common-account
. Este mecanismo utiliza la herramienta dedicada pam-auth-update
(provista por el paquete libpam-runtime). El administrador también puede utilizar esta herramienta si desea activar o desactivar módulos PAM.
./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
, pueda leer el archivo privado:
#
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
que utilice estas llaves para el cifrado. La configuración del servidor LDAP es gestionada de forma dinámica: puede actualizar la configuración con operaciones LDAP normales en la jerarquía de objetos cn=config
y el servidor actualizará /etc/ldap/slapd.d
en tiempo real para que la configuración sea persistente. Por lo tanto, ldapmodify
es la herramienta correcta para actualizar la configuración:
Ejemplo 11.24. Configuración de slapd
para cifrado
#
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
en el archivo /etc/default/slapd
. Para esta más seguros desactivaremos LDAP inseguro completamente.
Ejemplo 11.25. El archivo /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://
.
/usr/local/share/ca-certificates
y ejecutando 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
. Esto le ahorrará bastante tiempo.
Ejemplo 11.26. El archivo /etc/ldap/ldap.conf
# # Valores predeterminados para LDAP # # Revise ldap.conf(5) para más detalles # Este archivo debe poder ser leído (pero no escrito) por cualquiera. BASE dc=falcot,dc=com URI ldaps://ldap.falcot.com #SIZELIMIT 12 #TIMELIMIT 15 #DEREF never # Certificados TLC (necesarios para GnuTLS) TLS_CACERT /etc/ssl/certs/ca-certificates.crt