This is an update of the LDAP part of my diskless client project, which is documented on my old site at http://www.xs4all.nl/~rjb/ . This is work in progress (updated 27042009)... (to be merged for 9.04) $ dpkg-reconfigure slapd Omit OpenLDAP server configuration? No DNS domain name: your_domain.com Organization name: Your_organization Database backend to use: HDB Do you want the database to be removed when slapd is purged: Yes Move old database: Yes Administrator password: Allow LDAPv2 protocol: No /etc/phpldapadmin/config.php: :1,$ s/dc=example,dc=com/dc=your_domain,dc=com/g /etc/default/slapd: SLAPD_SERVICES="ldaps:/// ldap://127.0.0.1/" $ ldapmodify -x -D cn=admin,cn=config -W (password) dn: cn=config add: olcTLSCACertificateFile olcTLSCACertificateFile: /etc/ldap/slapd-cert.pem dn: cn=config add: olcTLSCertificateFile olcTLSCertificateFile: /etc/ldap/slapd-cert.pem dn: cn=config add: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ldap/slapd-key.pem ^D (end of merge) Reference: https://help.ubuntu.com/9.04/serverguide/C/openldap-server.html Installing the softwareLet's install the software: aptitude install slapd ldap-utils libpam-ldap libnss-ldap migrationtools phpldapadmin In case you're wondering what all of this does, simply said:
When installing slapd, the system will ask what password to use for the administrator. Just invent one and remember it. When installing ldap-auth-config, the system will ask for URI of the LDAP server, which in our case will look something like this: ldaps://server_hostname/ Replace Please note that in Ubuntu 8.04 or later a hostname is required; an IP address will not work anymore for secure connections. Using ldaps instead of ldap or ldapi, enables us to use encrypted connections over the network. So if you want to use an LDAP server on machine A for authenticating users on machine B, you can do that without sending plain-text passwords over the network. It will also ask for the distinguished name of the search base. The what? :-) Let's say it's a bit like the search domain in DNS, which in our case would be dc=mydomain,dc=com You will have to replace Answer Running the LDAP server: slapd(obsolete part to be removed) The configuration file for
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
pidfile /var/run/slapd/slapd.pid
argsfile /var/run/slapd/slapd.args
loglevel none
modulepath /usr/lib/ldap
moduleload back_hdb
sizelimit 500
tool-threads 1
backend hdb
database config
rootdn "cn=admin,cn=config"
rootpw {MD5}xxxxxxxxxxxxxxxxxxxxxxx
database hdb
suffix "dc=mydomain,dc=com"
directory "/var/lib/ldap"
dbconfig set_cachesize 0 2097152 0
dbconfig set_lk_max_objects 1500
dbconfig set_lk_max_locks 1500
dbconfig set_lk_max_lockers 1500
index objectClass eq
lastmod on
checkpoint 512 30
password-hash {md5}
TLSCertificateFile /etc/ldap/slapd-cert.pem
TLSCertificateKeyFile /etc/ldap/slapd-key.pem
TLSCACertificateFile /etc/ldap/slapd-cert.pem
rootdn "cn=Manager,dc=mydomain,dc=com"
rootpw {MD5}xxxxxxxxxxxxxxxxxxxxxxxx
access to attrs=userPassword
by dn="uid=root,ou=People,dc=mydomain,dc=com" write
by anonymous auth
by self write
by * none
access to *
by dn="uid=root,ou=People,dc=mydomain,dc=com" write
by * read
Note that the 3rd block is for converting the (obsolete) The MD5 hash above needs to be replaced by the hash returned by the following command:
slappasswd -h {md5}
When asked for a password, you need to type the new password for the LDAP Manager, which is like the "root" user in Unix. Just invent a password and remember it. When you are finished editing slaptest -f slapd.conf -F slapd.d chown -R openldap:openldap slapd.d chmod 600 slapd.conf mv -i slapd.conf slapd.conf.bak The last command will prevent (end of obsolete part) Configure slapd: $ dpkg-reconfigure slapd Omit OpenLDAP server configuration? No DNS domain name: your_domain.com Organization name: Your_organization Database backend to use: HDB Do you want the database to be removed when slapd is purged: Yes Move old database: Yes Administrator password: Allow LDAPv2 protocol: No The DNS domain name will be converted to a "distinguished name of the search base" mentioned earlier. Earlier we specified it for the clients, now we do the same for the server. Create a self-signed certificate and key pair. Type: cd /etc/ldap openssl req -new -x509 -nodes \ -out slapd-cert.pem -keyout slapd-key.pem -days 999999 chmod 644 slapd-cert.pem chown openldap:openldap slapd-key.pem chmod 400 slapd-key.pem When asked for Please note that in Ubuntu 8.04 or later a hostname is required; an IP address will not work anymore for secure connections. Tell slapd about the certificate: $ ldapmodify -x -D cn=admin,cn=config -W (password) dn: cn=config add: olcTLSCACertificateFile olcTLSCACertificateFile: /etc/ldap/slapd-cert.pem dn: cn=config add: olcTLSCertificateFile olcTLSCertificateFile: /etc/ldap/slapd-cert.pem dn: cn=config add: olcTLSCertificateKeyFile olcTLSCertificateKeyFile: /etc/ldap/slapd-key.pem Hit Ctrl-D to end the input. Edit SLAPD_SERVICES="ldaps:/// ldap://127.0.0.1/" Type: /etc/init.d/slapd restart If this fails, try to debug it using: slapd -d -1 -g openldap -u openldap -F /etc/ldap/slapd.d If you see something like: main: TLS init def ctx failed: -64 check if the TLS paths in (probably obsolete; it may have been merged in /etc/ldap.conf) The configuration file for the LDAP clients in BASE dc=mydomain,dc=com URI ldaps://your_hostname:636/ TLS_REQCERT allow (end of obsolete part) Test the LDAP server: ldapsearch -D "cn=admin,dc=mydomain,dc=com" -W -x ldapsearch -H 'ldaps://your_hostname/' -D "cn=admin,dc=mydomain,dc=com" -W -x ldapsearch -H 'ldap://127.0.0.1/' -D "cn=admin,dc=mydomain,dc=com" -W -x ldapsearch -W -x You need to type the LDAP manager password for the first 3 commands. At the last command just type enter: here we test the anonymous login. In Ubuntu 8.04 you really need the hostname in the second command instead of the IP address. If you see something like: result: 32 No such object that's ok. If you see something like: ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1) check if Migrating the files in /etc to LDAPNext task is to convert # $DEFAULT_MAIL_DOMAIN = "padl.com"; $DEFAULT_BASE = "dc=mydomain,dc=com"; # $DEFAULT_MAIL_HOST = "mail.padl.com"; $EXTENDED_SCHEMA = 1; Type: ./migrate_base.pl > /tmp/base.ldif ./migrate_passwd.pl /etc/passwd /tmp/passwd.ldif ./migrate_group.pl /etc/group /tmp/group.ldif ldapadd -D "cn=Manager,dc=mydomain,dc=com" -W -x -f /tmp/base.ldif ldapadd -D "cn=Manager,dc=mydomain,dc=com" -W -x -f /tmp/passwd.ldif ldapadd -D "cn=Manager,dc=mydomain,dc=com" -W -x -f /tmp/group.ldif rm /tmp/base.ldif /tmp/passwd.ldif /tmp/group.ldif Note that A web GUI for LDAP: phpldapadminEdit the following lines in
$config->custom->session['blowfish'] = 'some random string';
$ldapservers->SetValue($i,'server','name','My LDAP Server');
$ldapservers->SetValue($i,'server','host','ldap://127.0.0.1/');
$ldapservers->SetValue($i,'server','port','389');
$ldapservers->SetValue($i,'server','base',array('dc=mydomain,dc=com'));
$ldapservers->SetValue($i,'server','auth_type','session');
$ldapservers->SetValue($i,'login','dn','');
$ldapservers->SetValue($i,'login','pass','');
$ldapservers->SetValue($i,'server','tls',false);
$ldapservers->SetValue($i,'server','low_bandwidth',false);
$ldapservers->SetValue($i,'appearance','password_hash','md5');
$ldapservers->SetValue($i,'login','attr','dn');
Replace Assuming you already have Apache, PHP and a webbrowser installed, startup a webbrowser and go to https://localhost/phpldapadmin/. Login as This is a perfect moment to cleanup the LDAP. Remove everything, except Configuring the system to use LDAPEdit
These changes are needed for security by using Edit passwd: files ldap group: files ldap shadow: files ldap Check if LDAP works with NSS: getent passwd | grep 0:0 You should see 2 identical lines, one coming from Setting up PAM to work with LDAPEdit auth sufficient pam_unix.so nullok_secure auth requisite pam_ldap.so use_first_pass Edit account sufficient pam_unix.so account required pam_ldap.so Edit password sufficient pam_unix.so nullok obscure min=4 max=8 md5 password requisite pam_ldap.so Edit session required pam_env.so readenv=1 session required pam_unix.so session optional pam_ldap.so session required pam_mkhomedir.so skel=/etc/skel/ umask=077 session optional pam_foreground.so The first line has nothing to do with LDAP. It's there to read In order to turn off the caching of hosts, edit this line in enable-cache hosts no Check if LDAP works with PAM. When you change a password, the corresponding password hash in the LDAP should also change, and you should be able to use this new password anywhere. Recovering from a crashIf you cannot start db4.2_recover -c -h -v /var/lib/ldap After that, Diskless client hangs during boot when using LDAPIf the client hangs at:
|
|||
