CentOS7
yum install -y openldap-clients nss-pam-ldapd
authconfig --enableldap --enableldapauth --ldapserver=192.168.0.1:4464 --ldapbasedn="dc=hpc,dc=example,dc=com,dc=cn" --enablemkhomedir --update
systemctl enable nslcd
systemctl restart nslcd
Rocky8.7
yum -y install openldap openldap-clients authselect-compat nss-pam-ldapd nscd &>> ${LogFileDetail}
sed -i -e "s/^uri.*$/uri ldap\:\/\/192.168.0.1\:4464/g" -e "s/^base.*$/base dc=hpc,dc=example,dc=com,dc=cn/g" /etc/nslcd.conf
grep "^passwd" /etc/nsswitch.conf | grep -q ldap ||sed -i "/^passwd/ s/$/ ldap/g" /etc/nsswitch.conf
grep "^group" /etc/nsswitch.conf | grep -q ldap ||sed -i "/^group/ s/$/ ldap/g" /etc/nsswitch.conf
grep -q pam_mkhomedir.so /etc/pam.d/system-auth || echo session required pam_mkhomedir.so umask=0077 >> /etc/pam.d/system-auth
systemctl restart nscd nslcd