如何設定 ldap 登入服務 – OpenLDAP Linux authentication howto

OpenLDAP 登入服務器 上文提到如何安裝 OpenLDAP 服務器, 今次將會提到如何在 ubuntu上把 OpenLDAP 服務器設定成一個登入服務器. 這樣你就可以使用同一組資料登入多個不同的服務器. 先作服務器端設定 安裝轉換工具 migration tools sudo apt-get install migrationtools更改 migration_common.ph 設定檔, 位置在 /usr/share/perl5sudo vi /usr/share/perl5/migration_common.ph根據服務器端的設計更改以下兩行# Default DNS domain$DEFAULT_MAIL_DOMAIN = “example.com”;# Default base$DEFAULT_BASE = “dc=example,dc=com”;開始轉移登入資料 (/tmp 改成你的理想位置)export ETC_SHADOW=/etc/shadow #把shadow 跟passwd 一同載入./migrate_base.pl > /tmp/base.ldif./migrate_group.pl /etc/group /tmp/group.ldif./migrate_hosts.pl /etc/hosts /tmp/hosts.ldif./migrate_passwd.pl /etc/passwd /tmp/passwd.ldif用以下命令分別載入到 ldap 服務器ldapadd -D “cn=admin,dc=domain,dc=com” -W -f /tmp/base.ldifldapadd -D “cn=admin,dc=domain,dc=com” -W -f /tmp/group.ldifldapadd -D “cn=admin,dc=domain,dc=com” -W -f /tmp/passwd.ldifldapadd -D “cn=admin,dc=domain,dc=com” -W -f /tmp/hosts.ldifapt-get install 安裝認證需要的元件Modules require for authenticationlibnss-ldap – NSS module for using LDAP as a naming servicelibpam-ldap – Pluggable Authentication Module allowing LDAP interfaceslibnss-ldapd – NSS module for using LDAP as a naming serviceperdition-ldap – Library to allow perdition to access LDAP based popmapslibpam-cracklibpam library做小許 bug fixln -s pam_unix.so pam_pwdb.so這樣, 服務器端的設定就完成了 再做客戶端的設定 Vi /etc/ldap.confhost ldap.example.comuri ldap://<服務器ip位置>:389/base ou=People,dc=example,dc=comnss_initgroups_ignoreusers backup,bin,daemon,dhcp,games,gnats,irc,klog,libuuid,list,lp,mail,man,munin,mysql,news,openldap,proxy,root,sshd,sync,sys,syslog,uucp,www-datavi /etc/nsswitch.conf # 登入方法設定passwd: ldap compatshadow: ldap compatgroup: ldap compatvi /etc/pam.d/common-account #設定 account 認證方法account sufficient pam_ldap.soaccount required pam_unix.so try_first_passvi /etc/pam.d/common-auth # 設定登入認證方法auth sufficient pam_ldap.soauth requisite pam_unix.so nullok_secure try_first_passauth optional pam_smbpass.so migrate missingokvi /etc/pam.d/common-password #設定密碼管理password sufficient pam_ldap.sopassword required pam_unix.so nullok obscure min=4 max=8 md5 try_first_passpassword optional pam_smbpass.so nullok use_authtok use_first_pass missingok 測試設定 getent passwd | grep 會發現參數出現兩次這樣客戶端就能使用中央使用者管理

Unit B2, 10/F, Blk B, Mei Hing Ind. Building, 16-18 Hing Yip St.,
Kwun Tong, KLN, HK
General Enquiry: info@yubis.net
Website: http://www.yubis.net