在CentOS6.5上安裝OpenLDAP並配置LDAP方式使用者登入

來源:互聯網
上載者:User

在CentOS6.5上安裝OpenLDAP並配置LDAP方式使用者登入
1.安裝PHP和apache 如果沒有EPEL的源需要安裝下 yum install epel-release 若沒有下載下來,就建立/etc/yum.repo.d/epel.repo

[epel]name=Extra Packages for Enterprise Linux 6 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6[epel-debuginfo]name=Extra Packages for Enterprise Linux 6 - $basearch - Debug#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debugmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=1[epel-source]name=Extra Packages for Enterprise Linux 6 - $basearch - Source#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMSmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=1
phpldapadmin依賴apache和php
yum install php httpd 配置httpd.conf
2.安裝OpenLDAP yum install *openldap* openldap openldap-servers openldap-clients 配置OpenLDAP,設定檔/etc/openldap/slapd.conf 該檔案預設沒有,從/usr/share/openldap-servers/slapd.conf.obsolete拷貝一份到該位置 owner為ldap:ldap
database monitoraccess to *by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" readby dn.exact="cn=Manager,dc=iflyyun,dc=cn" readby * none database bdbsuffix "dc=iflyyun,dc=cn"checkpoint 1024 15rootdn "cn=Manager,dc=iflyyun,dc=cn"
配置/etc/openldap/ldap.confBASE dc=iflyyun,dc=cn
URI ldap://bja-pro0002.hadoop.cpcc.iflyyun.cn配置ldap管理使用者密碼 sldappasswd(注意不要用ldappasswd,否則會報GSSAPI錯誤) 輸入密碼,獲得{SSHA}ph+VRzfWSeamboy0itVlazrJrxzVHh80格式的密碼再修改/etc/openldap/slapd.conf 直接使用純文字密碼,使用加密密碼有點問題 配置apache識別index.php 修改/etc/httpd/conf/httpd.conf 找到下面這一行,添加index.php DirectoryIndex index.html index.html.var index.php 修改/etc/httpd/conf.d/php.conf 測試OpenLDAP設定檔是否正確: slaptest -u -f /etc/openldap/slapd.conf
3.安裝phpldapadmin yum install phpldapadmin 配置/etc/phpldapadmin/config.ini$servers->setValue('server','host','192.168.51.211');
$servers->setValue('server','port',389);
$servers->setValue('server','base',array('dc=iflyyun,dc=cn'));
$servers->setValue('login','auth_type','cookie');
$servers->setValue('login','bind_id','cn=Manager,dc=iflyyun,dc=cn');
$servers->setValue('login','attr','dn');(397行,這行取消注釋)
// $servers->setValue('login','attr','uid');(將這行注釋掉,否則登入會報錯)修改/etc/httpd/conf.d/phpldapadmin.conf,允許從其他機器訪問
Order Deny,Allow
Allow from all

4.phpldapadmin配置 刪除/etc/openldap/lapd.d/目錄下的所有檔案 建立LDAP根目錄 ldapadd -x -D"cn=Manager,dc=iflyyun,dc=cn" -f base.ldif -W base.ldifdn: dc=iflyyun,dc=cn
o: ldap
objectclass: dcObject
objectclass: organization建立管理使用者 # Manager, iflyyun.cn
dn: cn=Manager,dc=iflyyun,dc=cn
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: Manager
description: LDAP administrator
5.LDAP用戶端配置 安裝必備軟體 yum install nss-pam-ldapd pam_ldap openldap-clients 需要修改的設定檔有: /etc/sysconfig/authconfig、/etc/pam.d/system-auth、/etc/openldap/ldap.conf、/etc/nssswitch.conf 修改/etc/sysconfig/authconfig
IPADOMAINJOINED=noUSEMKHOMEDIR=yesUSEPAMACCESS=noCACHECREDENTIALS=yesUSESSSDAUTH=noUSESHADOW=yesUSEWINBIND=noUSEDB=no FORCELEGACY=noUSEFPRINTD=yesFORCESMARTCARD=noPASSWDALGORITHM=yesUSELDAPAUTH=yesUSEPASSWDQC=noIPAV2NONTP=noUSELOCAUTHORIZE=yesUSECRACKLIB=yesUSEIPAV2=noUSEWINBINDAUTH=noUSESMARTCARD=noUSELDAP=yesUSENIS=noUSEKERBEROS=noUSESYSNETAUTH=yesUSESSSD=noUSEHESIOD=no
修改/etc/pam.d/system-auth
#%PAM-1.0# This file is auto-generated.# User changes will be destroyed the next time authconfig is run.auth required pam_env.soauth sufficient pam_fprintd.soauth sufficient pam_ldap.soauth sufficient pam_unix.so nullok try_first_passauth requisite pam_succeed_if.so uid >= 500 quietauth required pam_deny.soaccount required pam_unix.soaccount sufficient pam_localuser.soaccount sufficient pam_succeed_if.so uid < 500 quietaccount required pam_permit.soaccount required pam_ldap.sopassword requisite pam_cracklib.so try_first_pass retry=3 type=password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtokpassword sufficient pam_ldap.so use_authtok md5password required pam_deny.sosession optional pam_keyinit.so revokesession required pam_limits.sosession [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uidsession required pam_unix.sosession required pam_mkhomedir.so skel=/etc/skel/ umask=0022session optional pam_ldap.so

修改/etc/openldap/ldap.conf
## LDAP Defaults## See ldap.conf(5) for details# This file should be world readable but not world writable.#BASE dc=example,dc=com#URI ldap://ldap.example.com ldap://ldap-master.example.com:666#SIZELIMIT 12#TIMELIMIT 15#DEREF neverTLS_CACERTDIR /etc/openldap/cacerts


BASE dc=iflyyun,dc=cn
URI ldap://hfa-pro0002.hadoop.cpcc.iflyyun.cn
修改/etc/nssswitch.conf
## /etc/nsswitch.conf## An example Name Service Switch config file. This file should be# sorted with the most-used services at the beginning.## The entry '[NOTFOUND=return]' means that the search for an# entry should stop if the search in the previous entry turned# up nothing. Note that if the search failed due to some other reason# (like no NIS server responding) then the search continues with the# next entry.## Valid entries include:## nisplus Use NIS+ (NIS version 3)# nis Use NIS (NIS version 2), also called YP# dns Use DNS (Domain Name Service)# files Use the local files# db Use the local database (.db) files# compat Use NIS on compat mode# hesiod Use Hesiod for user lookups# [NOTFOUND=return] Stop searching if not found so far## To use db, put the "db" in front of "files" for entries you want to be# looked up first in the databases## Example:#passwd: db files nisplus nis#shadow: db files nisplus nis#group: db files nisplus nispasswd: files ldapshadow: files ldapgroup: files ldap#hosts: db files nisplus nis dnshosts: files dns# Example - obey only what nisplus tells us...#services: nisplus [NOTFOUND=return] files#networks: nisplus [NOTFOUND=return] files#protocols: nisplus [NOTFOUND=return] files#rpc: nisplus [NOTFOUND=return] files#ethers: nisplus [NOTFOUND=return] files#netmasks: nisplus [NOTFOUND=return] filesbootparams: nisplus [NOTFOUND=return] filesethers: filesnetmasks: filesnetworks: filesprotocols: filesrpc: filesservices: filesnetgroup: nispluspublickey: nisplusautomount: files nisplusaliases: files nisplus
開啟名稱快取服務 service nscd restart

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.