How To Pressed LDAP Configuration in non-interactive mode ?
LDAP Server Configuration :
1. install the following packages using apt-get
apt-get install -y aptitude
apt-get install -y expect
apt-get install -y debconf-utils
2. install slapd in noninteractive mode
aptitude update
aptitude install expect
VAR=$(expect -c '
spawn aptitude -y install slapd
expect "New password for the slapd \"root\" user:"
send "123\r"
expect "Repeat password for the slapd \"root\" user:"
send "123\r"
expect eof
')
echo "$VAR"
aptitude -y install slapd
3. Configure slapd from backend
debconf-get-selections | grep "slapd" (Displays all parameters of "slapd")
echo slapd slapd/no_configuration boolean false | sudo debconf-set-selections
echo slapd slapd/domain string ldap.com | sudo debconf-set-selections
echo slapd shared/organization string ldap.com | sudo debconf-set-selections
echo slapd slapd slapd/password1 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/password2 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/adminpw password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/generated_adminpw password 123 | sudo debconf-set-selections
echo slapd slapd/backend select HDB | sudo debconf-set-selections
echo slapd slapd/purge_database boolean false | sudo debconf-set-selections
echo slapd slapd/move_old_database boolean true | sudo debconf-set-selections
echo slapd slapd/allow_ldap_v2 boolean false | sudo debconf-set-selections
LDAP Client Configuration :
1. install Dependency packages
sudo apt-get install -y debconf-utils
sudo apt-get install -y aptitude
2. install ldap-auth-client package in noninteractive mode
sudo DEBIAN_FRONTEND=noninteractive aptitude install -y -q ldap-auth-client
3. Configure ldap-auth client package from backend
echo ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap://192.168.1.1/ | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/base-dn string dc=ldap,dc=com | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3 | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dbrootlogin boolean true | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dblogin boolean false | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/rootbinddn string cn=admin,dc=ldap,dc=com | sudo debconf-set-selections
LDAP Server Configuration :
1. install the following packages using apt-get
apt-get install -y aptitude
apt-get install -y expect
apt-get install -y debconf-utils
2. install slapd in noninteractive mode
aptitude update
aptitude install expect
VAR=$(expect -c '
spawn aptitude -y install slapd
expect "New password for the slapd \"root\" user:"
send "123\r"
expect "Repeat password for the slapd \"root\" user:"
send "123\r"
expect eof
')
echo "$VAR"
aptitude -y install slapd
3. Configure slapd from backend
debconf-get-selections | grep "slapd" (Displays all parameters of "slapd")
echo slapd slapd/no_configuration boolean false | sudo debconf-set-selections
echo slapd slapd/domain string ldap.com | sudo debconf-set-selections
echo slapd shared/organization string ldap.com | sudo debconf-set-selections
echo slapd slapd slapd/password1 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/password2 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/adminpw password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/generated_adminpw password 123 | sudo debconf-set-selections
echo slapd slapd/backend select HDB | sudo debconf-set-selections
echo slapd slapd/purge_database boolean false | sudo debconf-set-selections
echo slapd slapd/move_old_database boolean true | sudo debconf-set-selections
echo slapd slapd/allow_ldap_v2 boolean false | sudo debconf-set-selections
4. Change in file Configurations
sed -i 's/#BASE/BASE/g' /etc/ldap/ldap.conf
sed -i 's/dc=example/dc=ldap/g' /etc/ldap/ldap.conf
sed -i '9d' /etc/ldap/ldap.conf
sed -i "9i URI ldap://localhost" /etc/ldap/ldap.conf
LDAP Client Configuration :
1. install Dependency packages
sudo apt-get install -y debconf-utils
sudo apt-get install -y aptitude
2. install ldap-auth-client package in noninteractive mode
sudo DEBIAN_FRONTEND=noninteractive aptitude install -y -q ldap-auth-client
3. Configure ldap-auth client package from backend
echo ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap://192.168.1.1/ | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/base-dn string dc=ldap,dc=com | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3 | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dbrootlogin boolean true | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dblogin boolean false | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/rootbinddn string cn=admin,dc=ldap,dc=com | sudo debconf-set-selections
4. make changes in configuration files
- set the ldap server ip in ldap.conf
sed -i 's/uri ldapi:\/\/\//uri ldap:\/\/192.168.1.1\//g' /etc/ldap.conf
- set base dn in /etc/ldap.conf
sed -i 's/base dc=example,dc=net/base dc=ldap,dc=com/g' /etc/ldap.conf
sed -i 's/rootbinddn cn=manager,dc=example,dc=net/rootbinddn cn=admin,dc=ldap,dc=com/g' /etc/ldap.conf
- save password in /etc/ldap.secret file
echo "123" >/etc/ldap.secret
sudo chmod 600 /etc/ldap.secret
do you know why debconf doesn't automatically change ldap.conf settings on the client side ?
ReplyDelete