В наших предыдущих статьях мы обсуждали установку сервера LDAP в Ubuntu 18.04 / 16.04 и настройку клиента LDAP в Ubuntu 18.04 / 16.04.
Как настроить клиент LDAP для подключения внешней аутентификации
В этом кратком руководстве рассматривается защита LDAP-сервера с помощью сертификата и ключа SSL / TLS.
У вас есть два варианта получения сертификата SSL, используемого для защиты Сервера LDAP.
- Использование самоподписанного SSL-сертификата
- Приобретение SSL-сертификатов от доверенного центра сертификации.
Это руководство объяснит использование самоподписанных сертификатов. Итак, начнем.
Шаг 1: Генерация самоподписанных сертификатов SSL
Войдите на сервер LDAP и создайте сертификаты SSL для использования.
# cd /etc/ssl/private # openssl genrsa -aes128 -out ldap_server.key 4096 Generating RSA private key, 4096 bit long modulus …………………………………………………………………………………..++ ………………………………….++ e is 65537 (0x010001) Enter pass phrase for ldap_server.key: <Set passphrase> Verifying - Enter pass phrase for ldap_server.key: <Confirm passphrase
Удалите парольную фразу из сгенерированного закрытого ключа:
# openssl rsa -in ldap_server.key -out ldap_server.key Enter pass phrase for ldap_server.key: <Enter passphrase> writing RSA key
Генерация CSR.
# openssl req -new -days 3650 -key ldap_server.key -out ldap_server.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. Country Name (2 letter code) [AU]:KE State or Province Name (full name) [Some-State]:Nairobi Locality Name (eg, city) []:Nairobi Organization Name (eg, company) [Internet Widgits Pty Ltd]:Computingforgeeks Organizational Unit Name (eg, section) []:Computingforgeeks Common Name (e.g. server FQDN or YOUR name) []:ldap.example.com Email Address []:admin@example.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
Затем подпишите свой сертификат:
# openssl x509 -in ldap_server.csr -out ldap_server.crt -req -signkey ldap_server.key -days 3650 Signature ok subject=C = KE, ST = Nairobi, L = Nairobi, O = Computingforgeeks, OU = Computingforgeeks, CN = ldap.example.com, emailAddress = admin@example.com Getting Private key
Шаг 2. Настройте SSL на сервере LDAP
Скопируйте сертификаты и ключ в каталог /etc/ldap/sasl2/.
cp /etc/ssl/private/{ldap_server.key,ldap_server.crt} /etc/ssl/certs/ca-certificates.crt /etc/ldap/sasl2/
Установите право собственности на сертификаты для пользователя openldap.
chown -R openldap. /etc/ldap/sasl2
Настройте сервер LDAP для использования сертификатов SSL.
Создайте файл конфигурации LDAP для SSL,
# vim ldap_ssl.ldif dn: cn=config changetype: modify add: olcTLSCACertificateFile olcTLSCACertificateFile: /etc/ldap/sasl2/ca-certificates.crt replace: olcTLSCertificateFile olcTLSCertificateFile: /etc/ldap/sasl2/ldap_server.crt replace: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ldap/sasl2/ldap_server.key
Примените конфигурацию, используя следующую команду.
# ldapmodify -Y EXTERNAL -H ldapi:/// -f ldap_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"
Шаг 3. Настройте клиента LDAP
Настройте клиент LDAP, чтобы обеспечить шифрование соединения между клиентом и сервером.
Добавьте разрешающую строку LS_REQCERT в /etc/ldap/ldap.conf.
echo "TLS_REQCERT allow" | tee /etc/ldap/ldap.conf
Теперь настройте механизм OpenLDAP SSL, раскомментировав строки ниже в файле /etc/ldap.conf.
# vim /etc/ldap.conf ssl start_tls ssl on
Теперь вы можете пользоваться SSL-соединением между LDAP-клиентом и сервером.
Приветствую.
Спасибо за статью.
После ldapmodify -Y EXTERNAL -H ldapi:/// -f ldap_ssl.ldif
ldapmodify: wrong attributeType at line 5, entry “cn=config”
Добрый день!
На багзилла такой фикс:
changetype: modify
add: objectClass