Ubuntu Server Guide
Download 1.23 Mb. Pdf ko'rish
|
ubuntu-server-guide (1)
Resources
• The primary resource is the upstream documentation: www.openldap.org • Zytrax’s LDAP for Rocket Scientists; a less pedantic but comprehensive treatment of LDAP 205 • A Ubuntu community OpenLDAP wiki page has a collection of notes • O’Reilly’s LDAP System Administration (textbook; 2003) • Packt’s Mastering OpenLDAP (textbook; 2007) LDAP & TLS 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). Here, we will be our own Certificate Authority and then create and sign our LDAP server certificate as that CA. This guide will use the certtool utility to complete these tasks. For simplicity, this is being done on the OpenLDAP server itself, but your real internal CA should be elsewhere. Install the gnutls-bin and ssl-cert packages: sudo apt i n s t a l l g n u t l s −b i n s s l −c e r t Create a private key for the Certificate Authority: sudo c e r t t o o l −−g e n e r a t e −p r i v k e y −−b i t s 4096 −− o u t f i l e / e t c / s s l / p r i v a t e / mycakey . pem Create the template/file /etc/ ssl /ca. info to define the CA: cn = Example Company ca c e r t _ s i g n i n g _ k e y e x p i r a t i o n _ d a y s = 3650 Create the self-signed CA certificate: sudo c e r t t o o l −−g e n e r a t e −s e l f −s i g n e d \ −−load −p r i v k e y / e t c / s s l / p r i v a t e /mycakey . pem \ −−t e m p l a t e / e t c / s s l / ca . i n f o \ −− o u t f i l e / u s r / l o c a l / s h a r e / ca− c e r t i f i c a t e s / mycacert . c r t Note Yes, the –outfile path is correct, we are writing the CA certificate to /usr/local/share/ca- certificates. This is where update-ca-certificates will pick up trusted local CAs from. To pick up CAs from /usr/share/ca-certificates, a call to dpkg−reconfigure ca−certificates is necessary. Run update−ca−certificates to add the new CA certificate to the list of trusted CAs. Note the one added CA: $ sudo update−ca− c e r t i f i c a t e s Updating c e r t i f i c a t e s i n / e t c / s s l / c e r t s . . . 1 added , 0 removed ; done . Running hooks i n / e t c / ca− c e r t i f i c a t e s / update . d . . . done . This also creates a /etc/ ssl /certs/mycacert.pem symlink pointing to the real file in /usr/local/share/ca− certificates . Make a private key for the server: sudo c e r t t o o l −−g e n e r a t e −p r i v k e y \ −−b i t s 2048 \ −− o u t f i l e / e t c / l d a p / ldap01_slapd_key . pem 206 Note Replace ldap01 in the filename with your server’s hostname. Naming the certificate and key for the host and service that will be using them will help keep things clear. Create the /etc/ ssl /ldap01.info info file containing: o r g a n i z a t i o n = Example Company cn = l d a p 0 1 . example . com tls_www_server en cry pt io n_ ke y s i g n i n g _ k e y e x p i r a t i o n _ d a y s = 365 The above certificate is good for 1 year, and it’s valid only for the ldap01.example.com hostname. Adjust accordingly. Create the server’s certificate: sudo c e r t t o o l −−g e n e r a t e − c e r t i f i c a t e \ −−load −p r i v k e y / e t c / l d a p / ldap01_slapd_key . pem \ −−load −ca− c e r t i f i c a t e / e t c / s s l / c e r t s / mycacert . pem \ −−load −ca−p r i v k e y / e t c / s s l / p r i v a t e /mycakey . pem \ −−t e m p l a t e / e t c / s s l / l d a p 0 1 . i n f o \ −− o u t f i l e / e t c / l d a p / l d a p 0 1 _ s l a p d _ c e r t . pem Adjust permissions and ownership: sudo chgrp openldap / e t c / l d a p / ldap01_slapd_key . pem sudo chmod 0640 / e t c / l d a p / ldap01_slapd_key . pem Your server is now ready to accept the new TLS configuration. Create the file certinfo . ldif with the following contents (adjust paths and filenames accordingly): dn : cn=c o n f i g add : o l c T L S C A C e r t i f i c a t e F i l e o l c T L S C A C e r t i f i c a t e F i l e : / e t c / s s l / c e r t s / mycacert . pem − add : o l c T L S C e r t i f i c a t e F i l e o l c T L S C e r t i f i c a t e F i l e : / e t c / l d a p / l d a p 0 1 _ s l a p d _ c e r t . pem − add : o l c T L S C e r t i f i c a t e K e y F i l e o l c T L S C e r t i f i c a t e K e y F i l e : / e t c / l d a p / ldap01_slapd_key . pem Use the ldapmodify command to tell slapd about our TLS work via the slapd-config database: sudo l d a p m o d i f y −Y EXTERNAL −H l d a p i : / / / −f c e r t i n f o . l d i f Contratry to popular belief, you do not need ldaps:// in /etc/default/slapd in order to use encryption. You should have just: SLAPD_SERVICES=”l d a p : / / / l d a p i : / / / ” Note 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. 207 Certificate for an OpenLDAP replica To generate a certificate pair for an OpenLDAP replica (consumer), create a holding directory (which will be used for the eventual transfer) and: mkdir ldap02−s s l cd ldap02−s s l c e r t t o o l −−g e n e r a t e −p r i v k e y \ −−b i t s 2048 \ −− o u t f i l e ldap02_slapd_key . pem Create an info file, ldap02.info, for the Consumer server, adjusting its values accordingly: o r g a n i z a t i o n = Example Company cn = l d a p 0 2 . example . com tls_www_server en cry pt io n_ ke y s i g n i n g _ k e y e x p i r a t i o n _ d a y s = 365 Create the Consumer’s certificate: sudo c e r t t o o l −−g e n e r a t e − c e r t i f i c a t e \ −−load −p r i v k e y ldap02_slapd_key . pem \ −−load −ca− c e r t i f i c a t e / e t c / s s l / c e r t s / mycacert . pem \ −−load −ca−p r i v k e y / e t c / s s l / p r i v a t e /mycakey . pem \ −−t e m p l a t e l d a p 0 2 . i n f o \ −− o u t f i l e l d a p 0 2 _ s l a p d _ c e r t . pem Note We had to use sudo to get access to the CA’s private key. This means the generated certificate file is owned by root. You should change that ownership back to your regular user before copying these files over to the Consumer. Get a copy of the CA certificate: cp / e t c / s s l / c e r t s / mycacert . pem . We’re done. Now transfer the ldap02−ssl directory to the Consumer. Here we use scp (adjust accordingly): cd . . s c p −r ldap02−s s l user@consumer : On the Consumer side, install the certificate files you just transferred: sudo cp l d a p 0 2 _ s l a p d _ c e r t . pem ldap02_slapd_key . pem / e t c / l d a p sudo chgrp openldap / e t c / l d a p / ldap02_slapd_key . pem sudo chmod 0640 / e t c / l d a p / ldap02_slapd_key . pem sudo cp mycacert . pem / u s r / l o c a l / s h a r e / ca− c e r t i f i c a t e s / mycacert . c r t sudo update−ca− c e r t i f i c a t e s Create the file certinfo . ldif with the following contents (adjust accordingly regarding paths and filenames, if needed): dn : cn=c o n f i g add : o l c T L S C A C e r t i f i c a t e F i l e o l c T L S C A C e r t i f i c a t e F i l e : / e t c / s s l / c e r t s / mycacert . pem − 208 add : o l c T L S C e r t i f i c a t e F i l e o l c T L S C e r t i f i c a t e F i l e : / e t c / l d a p / l d a p 0 2 _ s l a p d _ c e r t . pem − add : o l c T L S C e r t i f i c a t e K e y F i l e o l c T L S C e r t i f i c a t e K e y F i l e : / e t c / l d a p / ldap02_slapd_key . pem Configure the slapd-config database: sudo l d a p m o d i f y −Y EXTERNAL −H l d a p i : / / / −f c e r t i n f o . l d i f Test: $ ldapwhoami −x −ZZ −h l d a p 0 2 . example . com anonymous Download 1.23 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling