-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathldap_setup.sh
More file actions
executable file
·26 lines (21 loc) · 827 Bytes
/
Copy pathldap_setup.sh
File metadata and controls
executable file
·26 lines (21 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Simple LDAP configuration for Ubuntu 18.04
# https://www.server-world.info/en/note?os=Ubuntu_18.04&p=openldap&f=3
# Install
apt install -y libnss-ldap libpam-ldap ldap-utils nscd
# Basic configuration
sed -i 's/\(\(passwd\|group\):.*\)/\1 ldap/g' /etc/nsswitch.conf
sed -i 's/\(pam_ldap\.so.*\)\( use_authtok\)/\1/g' /etc/pam.d/common-password
echo 'session optional\tpam_mkhomedir.so skel=/etc/skel umask=077' >> /etc/pam.d/common-session
# Shell and TLS configuration
cfg='nss_override_attribute_value loginShell /bin/bash
ssl start_tls
tls_checkpeer no'
echo "${cfg}" >> /etc/ldap.conf
# Add sudoers group
read -p "sudo group (empty to omit): " sugroup
if [ -n "${sugroup}" ]; then
echo "%${sugroup}\tALL=(ALL) ALL" >> /etc/sudoers
fi
# Restart daemons
systemctl restart systemd-logind libnss-ldap nscd