informatica:linux:openldap
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
informatica:linux:openldap [2013/05/23 14:09] – javi | informatica:linux:openldap [2017/11/16 10:22] – jose | ||
---|---|---|---|
Line 125: | Line 125: | ||
</ | </ | ||
- | NOTA: la contrasenya de los usuarios luego la cambiamos con phpldapmyadmin | + | NOTA: la contrasenya de los usuarios luego la cambiamos con [[phpldapadmin]] |
2. Ejecutar: | 2. Ejecutar: | ||
Line 323: | Line 323: | ||
5. Verificar: | 5. Verificar: | ||
- | ldapsearch -xLLL -b " | + | ldapsearch -x -LLL -b " |
Salida: | Salida: | ||
Line 359: | Line 359: | ||
</ | </ | ||
- | 6. A partir de aqui ya podriamos probar con PhpLdapAdmin: | + | 6. A partir de aqui ya podriamos probar con [[phpldapadmin]]: |
Login DN: cn=admin, | Login DN: cn=admin, | ||
Line 389: | Line 389: | ||
1. (Apache) Habilitar el modulo ldap | 1. (Apache) Habilitar el modulo ldap | ||
- | sudo a2enmod | + | sudo a2enmod |
- | 2. (Apache) Ejemplo de virtualhost: | + | ==== HTTP plano ==== |
+ | |||
+ | 1. (Apache) Ejemplo de virtualhost: | ||
< | < | ||
Line 405: | Line 407: | ||
< | < | ||
+ | | ||
order allow,deny | order allow,deny | ||
allow from all | allow from all | ||
+ | |||
AuthName " | AuthName " | ||
AuthType Basic | AuthType Basic | ||
AuthBasicProvider ldap | AuthBasicProvider ldap | ||
- | | + | |
+ | AuthLDAPBindDN cn=readonly, | ||
+ | AuthLDAPBindPassword clearpassword | ||
+ | | ||
require valid-user | require valid-user | ||
- | | + | </ |
ErrorLog ${APACHE_LOG_DIR}/ | ErrorLog ${APACHE_LOG_DIR}/ | ||
- | |||
# Possible values include: debug, info, notice, warn, error, crit, | # Possible values include: debug, info, notice, warn, error, crit, | ||
# alert, emerg. | # alert, emerg. | ||
LogLevel warn | LogLevel warn | ||
- | |||
CustomLog ${APACHE_LOG_DIR}/ | CustomLog ${APACHE_LOG_DIR}/ | ||
</ | </ | ||
Line 429: | Line 434: | ||
Ver [[http:// | Ver [[http:// | ||
- | 3. (Apache) Reiniciar Apache: | + | ==== TLS ==== |
- | sudo /etc/init.d/apache2 restart | + | 1. Configuracion del virtual host: |
- | 4. En un navegador teclear: | + | < |
+ | < | ||
+ | ServerName testldap.example.com | ||
+ | ServerAdmin webmaster@localhost | ||
+ | DocumentRoot / | ||
+ | |||
+ | < | ||
+ | Options FollowSymLinks | ||
+ | AllowOverride None | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | | ||
+ | order allow, | ||
+ | allow from all | ||
+ | |||
+ | AuthName " | ||
+ | AuthType Basic | ||
+ | AuthBasicProvider ldap | ||
+ | |||
+ | AuthLDAPBindDN cn=readonly, | ||
+ | AuthLDAPBindPassword clearpassword | ||
+ | AuthLDAPURL " | ||
+ | |||
+ | require valid-user | ||
+ | </ | ||
+ | |||
+ | ErrorLog ${APACHE_LOG_DIR}/ | ||
+ | # Possible values include: debug, info, notice, warn, error, crit, | ||
+ | # alert, emerg. | ||
+ | LogLevel warn | ||
+ | CustomLog ${APACHE_LOG_DIR}/ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 2. Crear el siguiente archivo: | ||
+ | |||
+ | sudo vim / | ||
+ | |||
+ | Con el siguiente contenido: | ||
+ | |||
+ | LDAPVerifyServerCert Off | ||
+ | |||
+ | 3. (TODO) Comprobar si es necesario reiniciar apache o con el reload de mas adelante es suficiente | ||
+ | |||
+ | ==== Comprobacion ==== | ||
+ | |||
+ | 1. (Apache) Reiniciar Apache: | ||
+ | |||
+ | sudo service apache2 reload | ||
+ | |||
+ | 2. En un navegador teclear: | ||
http:// | http:// | ||
Line 520: | Line 576: | ||
NOTA: si se utiliza ' | NOTA: si se utiliza ' | ||
+ | |||
===== TLS, SSL, STARTTLS, LDAPS ===== | ===== TLS, SSL, STARTTLS, LDAPS ===== | ||
- | 1. Seguir los pasos especificados en https:// | + | https:// |
- | 2. **IMPORTANTE** es recomendable habilitar ldaps, por lo tanto **SI** es necesario: | + | When authenticating to an OpenLDAP server it is best to do so using an encrypted session. This can be accomplished using Transport Layer Security (TLS). |
- | 2.1 Editar: | + | Here, we will be our own Certificate Authority and then create and sign our LDAP server certificate as that CA. Since slapd is compiled using the gnutls library, we will use the certtool utility to complete these tasks. |
+ | |||
+ | 1. Install the gnutls-bin and ssl-cert packages: | ||
+ | |||
+ | sudo apt-get install gnutls-bin ssl-cert | ||
+ | |||
+ | 2. Create a private key for the Certificate Authority: | ||
+ | |||
+ | sudo sh -c " | ||
+ | |||
+ | 3. Create the template/ | ||
+ | |||
+ | < | ||
+ | cn = Example Company | ||
+ | ca | ||
+ | cert_signing_key | ||
+ | </ | ||
+ | |||
+ | 4. Create the self-signed CA certificate: | ||
+ | |||
+ | sudo certtool --generate-self-signed --load-privkey / | ||
+ | |||
+ | 5. Make a private key for the server: | ||
+ | |||
+ | sudo certtool --generate-privkey --bits 1024 --outfile / | ||
+ | |||
+ | 6. Create the / | ||
+ | |||
+ | < | ||
+ | organization = Example Company | ||
+ | cn = ldap01.example.com | ||
+ | tls_www_server | ||
+ | encryption_key | ||
+ | signing_key | ||
+ | expiration_days = 3650 | ||
+ | </ | ||
+ | |||
+ | The above certificate is good for 10 years. Adjust accordingly. | ||
+ | |||
+ | 7. Create the server' | ||
+ | |||
+ | sudo certtool --generate-certificate --load-privkey / | ||
+ | |||
+ | 8. Create the file / | ||
+ | |||
+ | < | ||
+ | dn: cn=config | ||
+ | add: olcTLSCACertificateFile | ||
+ | olcTLSCACertificateFile: | ||
+ | - | ||
+ | add: olcTLSCertificateFile | ||
+ | olcTLSCertificateFile: | ||
+ | - | ||
+ | add: olcTLSCertificateKeyFile | ||
+ | olcTLSCertificateKeyFile: | ||
+ | </ | ||
+ | |||
+ | Use the ldapmodify command to tell slapd about our TLS work via the slapd-config database: | ||
+ | |||
+ | sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f / | ||
+ | |||
+ | 9. IMPORTANTE es recomendable habilitar ldaps, por lo tanto SI es necesario: | ||
+ | |||
+ | Editar: | ||
sudo vim / | sudo vim / | ||
Line 535: | Line 655: | ||
SLAPD_SERVICES=" | SLAPD_SERVICES=" | ||
- | 2.2 Reiniciar | + | Mas info: |
+ | |||
+ | |||
+ | LDAP over TLS/SSL (ldaps: / / ) is deprecated in favour of StartTLS. The latter refers to an existing | ||
+ | |||
+ | |||
+ | 10. Tighten up ownership and permissions: | ||
+ | |||
+ | sudo adduser openldap ssl-cert | ||
+ | sudo chgrp ssl-cert / | ||
+ | sudo chmod g+r / | ||
+ | sudo chmod o-r / | ||
+ | |||
+ | 11. Restart OpenLDAP: | ||
sudo service slapd restart | sudo service slapd restart | ||
- | -------------------------------------------------------------------------------- | + | 12. Comprobar: |
+ | |||
+ | sudo netstat | ||
+ | Salida esperada: | ||
+ | < | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | </ | ||
- | ^ Protocolo ^ Config.adicional servidor ^ Puerto ^ | + | ===== Modificar un registro |
- | | StartTLS | La descrita | + | Para añadir un campo, por ejemplo loginshell al usuario jur. Creeamos el fichero anyadir.ldif: |
- | | ldaps | La descrita en esta seccion. Editar '/etc/default/slapd' | 636 | | + | < |
+ | dn: cn=jur, | ||
+ | add: loginshell | ||
+ | loginshell: | ||
+ | </code> | ||
- | **IMPORTANTE**: | + | Lo añadimos con el comando: |
+ | ldapmodify -x -w ******** -D " | ||
+ | |||
+ | Para modificarlo, | ||
+ | < | ||
+ | dn: cn=jur, | ||
+ | changetype: modify | ||
+ | replace: loginshell | ||
+ | loginshell: /bin/sh | ||
+ | </ | ||
- | a) LDAP over TLS/SSL (ldaps://) is deprecated in favour of StartTLS. The latter refers to an existing LDAP session (listening on TCP port 389) becoming protected by TLS/SSL whereas LDAPS, like HTTPS, is a distinct encrypted-from-the-start protocol that operates over TCP port 636. | + | ldapmodify |
- | b) Hay todavia muchas aplicaciones que NO soportan StartTLS. | ||
- | c) En el lado servidor se realizan las configuraciones, en el lado cliente dependiendo | + | ===== Consulta sin corte de línea ===== |
+ | ldapsearch -D " | ||
+ | Con linux si tienes perl: | ||
+ | ldapsearch -D " | ||
+ | ===== Consulta | ||
+ | ldapsearch -D " | ||
+ | < | ||
+ | objectClasses: | ||
+ | objectClasses: | ||
+ | objectClasses: | ||
+ | objectClasses: | ||
+ | objectClasses: | ||
+ | objectClasses: | ||
+ | </ | ||
+ | | ||
informatica/linux/openldap.txt · Last modified: 2018/07/24 09:37 by javi