-
配置Ubuntu使用ldap认证将ubuntu配置为通过ldap认证,使其成为ldap client,本文实验环境为ubuntu 12.04。一、手工配置方式1、软件安装:Java代码apt-get install ldap-utils libpam-ldap libnss-ldap nslcd安装过程中提示填写ldap相关信息:ldap server 地址,base dc等,信息保存在/etc/ldap.conf中,可通过dpkg-reconfigure ldap-auth-config重新配置,其中:ldap服务uri格式 ldap://ldapServerIP/search base:dc=my,dc=com,dc=cnroot ldap account:cn=admin,dc=my,dc=com,dc=cn2、认证方式中添加ldap:Java代码root@ldapclient:~# auth-client-config -t nss -p lac_ldap3、使认证通过后自动创建用户家目录:Java代码vi /etc/pam.d/common-session,追加内容:session required pam_mkhomedir.so skel=/etc/skel umask=00224、配置开启ldap认证方式Java代码root@ldapclient:~# pam-auth-update5、执行Java代码update-rc.d nslcd enable6、配置可在本机通过passwd更改用户密码:Java代码vi /etc/pam.d/common-password,除去其中的use_authtok参数7、重启相关服务:Java代码/etc/init.d/nscd restart8、登陆或切换用户时即通过ldap进行认证,如切换为ldap中的用户manager:Java代码user1@ldapclient:~$ su - managerPassword:*****Creating directory '/home/manager'.manager@ldapclient:~$参见http://askubuntu.com/questions/127389/how-to-configure-ubuntu-as-an-ldap-client二、脚本配置方式如果需配置的机器很多,采用手工配置方式不太合适,可在待配置机器上运行如下shell脚本进行自动化配置:C代码#!/bin/bash#--------------------------------------------------------------------------------#Ldap server地址及base DNLDAP_SERVER_IP=192.168.1.100BASE_DN='dc=my,dc=com,dc=cn'#--------------------------------------------------------------------------------#创建preseed文件-软件安装自应答touch debconf-ldap-preseed.txtecho "ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap://$LDAP_SERVER_IP" >> debconf-ldap-preseed.txtecho "ldap-auth-config ldap-auth-config/ldapns/base-dn string $BASE_DN" >> debconf-ldap-preseed.txtecho "ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3" >> debconf-ldap-preseed.txtecho "ldap-auth-config ldap-auth-config/dbrootlogin boolean false" >> debconf-ldap-preseed.txtecho "ldap-auth-config ldap-auth-config/dblogin boolean false" >> debconf-ldap-preseed.txtecho "nslcd nslcd/ldap-uris string ldap://$LDAP_SERVER_IP" >> debconf-ldap-preseed.txtecho "nslcd nslcd/ldap-base string $BASE_DN" >> debconf-ldap-preseed.txtcat debconf-ldap-preseed.txt | debconf-set-selections#安装ldap client相关软件apt-get install -y ldap-utils libpam-ldap libnss-ldap nslcd#认证方式中添加ldapauth-client-config -t nss -p lac_ldap#认证登录后自动创建用户家目录echo "session required pam_mkhomedir.so skel=/etc/skel umask=0022" >> /etc/pam.d/common-session#自启动服务update-rc.d nslcd enable#可以在Host上通过passwd更改用户密码cp /etc/pam.d/common-password /etc/pam.d/common-password.baksed -i 's/use_authtok//' /etc/pam.d/common-password#使配置生效/etc/init.d/nscd restart
ubuntu14.04ldap client install and configure
最新推荐文章于 2023-07-06 15:32:00 发布