From 59dd497c982c46e43f96108fccd1f04148d4f336 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Sun, 1 Apr 2018 21:37:44 +0200 Subject: [PATCH] suffix-change, simplified steps, password-recovery --- 00.suffix.ldif.sh | 13 ++++++ 20.passwordhash.ldif | 1 + 00.root.ldif.sh => 30.root.ldif.sh | 2 +- 90.user.ldif.sh | 2 +- 99.passwordrecovery.ldif.sh | 20 ++++++++++ README.md | 64 +++++++++++++++++++++++------- 6 files changed, 86 insertions(+), 16 deletions(-) create mode 100755 00.suffix.ldif.sh rename 00.root.ldif.sh => 30.root.ldif.sh (87%) create mode 100644 99.passwordrecovery.ldif.sh diff --git a/00.suffix.ldif.sh b/00.suffix.ldif.sh new file mode 100755 index 0000000..f254040 --- /dev/null +++ b/00.suffix.ldif.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +basedn=`cat basedn` + +cat <&2 cat <&2 + echo "random password will be printed. Use ldappasswd for changing it" >&2 + exit 1 +fi + +user="$1" +pw=`pwgen 8 1` +echo "# Password: $pw" >&2 + +cat < basedn`). +Pre +=== -For initialization, first shutdown slapd and delete the content of `/var/lib/ldap/` (you will loose all of your data!), -then use: +Install slapd and ldap-utils: - ./00.root.ldif.sh | slapadd -b `cat basedn` -v - chown -R openldap:openldap /var/lib/ldap/ + sudo aptitude install slapd ldap-utils -Now you can start slapd with your fresh config. +It will ask for eg. domain, password. +If your domain is `example.net`, your basedn will be `dc=example,dc=net`. +If you want to use an other basedn, for example `o=example,c=de`, +debian/ubuntu will not provide any way to do that. + +Thats because while these steps your database will be lost and you can choose your basedn. + +Add your basedn to file `basedn`: + + echo dc=example,dc=net > basedn + +Init +==== + +Usefull defaults for security (better Passwordhashes): + + ldapmodify -H ldapi:// -Y EXTERNAL -f 10.acls.ldif + ldapmodify -H ldapi:// -Y EXTERNAL -f 20.passwordhash.ldif + +BaseDN +====== + +These steps will erase your database. +If you do not want to change your BaseDN, skip this step. + +The next step will print your new password on STDERR, so note it. +You can change it any time. + + ./00.suffix.ldif.sh | sudo ldapmodify -H ldapi:// -Y external + ./30.root.ldif.sh | sudo -u openldap -i slapadd -vb `cat basedn` + +Clientconfig +============ Add these lines to `/etc/ldap/ldap.conf`: @@ -15,19 +46,24 @@ Add these lines to `/etc/ldap/ldap.conf`: URI ldapi:// EOF -Via `ldapadd -Y EXTERNAL` you can add any other ldif. - -For adding 10 and 20 use: [BROKEN, do it manually in `/etc/...`] - - ldapmodify -Y EXTERNAL -f 10.acls.ldif - ldapmodify -Y EXTERNAL -f 20.passwordhash.ldif +Add an user +=========== For adding an user run: - ./90.user.ldif.sh username givenname surname emailaddr | ldapadd -Y EXTERNAL + ./90.user.ldif.sh "$username" "$givenname" "$surname" "$emailaddr" | ldapadd -H ldapi:// -Y EXTERNAL It will print the password on STDERR. +The DN will be uid=$username,$basedn + +Changing Passwords +================== + For changing password use: - ldappasswd -xASD YOURDN + ldappasswd -xASD $yourdn + +If you forgot your password, the administator can change the password via: + + ./99.passwordrecovery.ldif.sh $yourdn| sudo ldapmodify -H ldapi:// -Y external