III (二十二)OpenLDAPphp
目錄服務:html
目錄是一類爲了瀏覽和搜索數據而設計的特殊的數據庫,目錄服務是按照樹狀形式存儲信息,目錄包含基於屬性的描述性信息,而且支持高級的過濾功能,如microsoft的active directory活動目錄就是目錄數據庫的一種;java
a directory is like a phone book,and is not like a directory(folder) on your computermysql
通常目錄不支持大多數事務型數據庫所支持的高吞吐量和複雜的更新操做,目錄進行更新操做是要麼所有要麼都不的原子操做;nginx
目錄服務適合的應用在於提供大量的查詢和搜索操做,而不是大量的寫入操做(讀多寫少);git
爲保證目錄數據的可用性和可靠性,在確保使用目錄服務提供快速查詢和搜索操做的同時,目錄服務還提供了主從server同步目錄數據信息的能力,同傳統的MySQL的主從同步功能同樣,甚至比MySQL的同步功能更多,ldap能夠有一主多從,最大限度的確保基於目錄業務的服務持續可用性與提供併發查詢能力,active directory就有主域和備份域的說法,ldap能夠說是active directory活動目錄在Linux上的開源實現;web
廣義的目錄服務概念,能夠用多種不一樣的方式來提供目錄服務,不一樣的目錄所容許存儲的信息是不一樣的,在信息如何被引用、查詢、更新及防止未經受權的訪問等問題上,不一樣的目錄服務的處理方式也有諸多不一樣;sql
舉例,一些目錄服務是本地的,只提供受限的服務(如單機上的finger服務);一些目錄服務是大範圍的global,面向internet提供廣闊的多的服務,一般是分佈的(數據是分佈在多臺機器上的),這些機器一塊兒來提供目錄服務,典型的大範圍服務定義一個統一的namespace名稱空間來給出一個相同的數據視圖data view,而無論具體數據所在位置,如DNS是一個典型的大範圍分佈式目錄服務的例子數據庫
ldap(lightweight directory access protocol),ldap是在X.500標準基礎上產生的一個簡化版本;apache
目錄服務一般有兩個國際標準,X.500和LDAP;
X.500是ITU-T和ISO定義的目錄標準,它實際上不是一個協議,而是由一個協議族組成,包括從X.501到X.525等一系列很是完整的目錄服務協議;
LDAP基於tcp/ip的目錄訪問協議,是internet上目錄服務的通用訪問協議,LDAP運行在tcp/ip或其它的面向鏈接的傳輸服務之上,LDAP完整的技術規範由RFC2251(LDAPv3)和其它幾個在RFC3377中定義的文檔組成;
從技術上說,LDAP是一個到X.500目錄服務的目錄訪問協議,X.500是一個OSI(open system interconnection)目錄服務,最初,LDAP客戶端經過網關訪問X.500目錄服務,網關在客戶端和X.500server之間,而X.500 DAP(directory access protocol)位於這個網關和X.500服務器之間;
DAP是一個重量級的協議,在整個OSI協議棧上進行操做,並且佔用大量計算機資源,而LDAP設計在tcp/ip層上操做,以小得多的代價實現了大多數DAP的功能,雖然LDAP仍可經過網關訪問X.500 server,但如今一般都是在X.500 server上直接實現LDAP;
單獨的LDAP守護進程slapd(openldap),可被看做是輕量級的X.500目錄服務器,也就是說它沒有實現X.500徹底的DAP協議,做爲一個輕量級的目錄服務器,slapd實現的僅是X.500模型的一個子集;
X.500爲網絡用戶提供分佈式目錄服務,它定義一個機構如何在一個企業的全局範圍內共享名字和與它們相關的對象,X.500規範整體命名方式,全球統一的名字空間,一個完整的X.500系統稱爲一個目錄,這個目錄是一個數據庫,或爲目錄信息數據庫;
X.500是層次性的,全部對象被組織成樹形結構,模仿一個機構的組織形式;
X.500目錄服務還可以實現身份認證、訪問控制、它被公認爲是實現一個目錄服務的最好途徑,可是它的實現須要很大投資,效率不高,在實際中存在很多障礙,DAP對相關層協議環境要求過多,在許多小系統上沒法使用,也不適應tcp/ip協議體系,所以IETF設計並定義LDAP做爲使用X.500目錄的更好的途徑;
X.500具有的特徵:
分散維護(運行X.500的每一個站點只負責本地目錄部分,可當即進行更新和維護操做);
搜索性能(X.500具備強大的搜索功能,支持用戶創建的任意複雜查詢);
單一全局命名空間(相似DNS,X.500爲用戶提供單一同性命名空間single homegeneous namespace,與DNS相比,X.500的命名空間更靈活且易於擴展);
結構化信息結構(X.500目錄中定義了信息結構,容許本地擴展);
基於標準的目錄服務(因爲X.500可被用於創建一個基於標準的目錄,在某種意義上,請求應用目錄信息(Email、資源自動分配器、特定目錄工具)的應用程序就能訪問重要且有價值的信息);
LDAP與X.500的相同點(LDAP是X.500標準中的目錄訪問協議DAP的一個子集,可用於創建X.500目錄,這兩個目錄服務技術標準有許多共同之處):
在平臺上,都實現了一個通用的平臺結構,提供了一個OS和application須要的信息服務類型,可被許多平臺和應用程序接收和實現;
在信息模型上,都使用了項、對象類、屬性等概念和模式來描述信息;
在命名空間方面,都使用了目錄信息樹結構和層次命名模型;
在功能模型上,都使用了類似的操做命令來管理目錄信息;
在認證框架方面,均可實現用戶名稱和密碼,或基於安全加密方式的認證機制;
在靈活性上,它們的目錄規模均可大可小,大到全球目錄樹,小到只有一臺目錄server;
在分佈性方面,目錄信息均可分佈在多個目錄服務器中,這些server能夠由各組織管理,既保證了目錄信息整體結構的一致性,又知足了分級管理的須要;
LDAP與X.500的差異:
LDAP基於internet tcp/ip,直接運行在更簡單和更通用的tcp/ip或其它可靠的傳輸協議層上,避免了在OSI會話層和表示層處理包操做的開銷,使鏈接的創建和包的處理更簡單、更快,對於互聯網和企業網應用更理想;
X.500基於OSI,創建在應用層上的DAP,須要在OSI會話層和表示層上進行許多的創建鏈接和包處理的任務,須要特殊的網絡軟件實現對網絡的訪問;
LDAP協議更爲簡單,它繼承了X.500最好的特性,同時去掉了X.500的複雜性,LDAP經過使用查找操做實現列表操做了讀操做,另外一方面省去了X.500中深奧的和不多使用的服務控制和安全特性,只保留經常使用的特性;
LDAP經過引用機制實現分佈式訪問,經過clientAPI實現分佈式操做平衡了負載(對於應用透明);
X.500 DSA經過server之間的鏈操做實現分佈式的訪問,這樣查詢的壓力集中於服務端;
LDAP的實現具備低費用、易配置和易管理的特色,經性能測試,LDAP比X.500具備更少的響應時間,LDAP提供了知足應用程序對目錄服務所需求的特性;
LDAP中經常使用名詞縮寫及含義:
dc(domain component,域名的部分,其格式是將完整的域名分紅幾部分,如example.com,dc=example,dc=com);
uid(user id,用戶ID);
ou(organization unit,組織單位,相似於LinuxFS的子目錄,它是一個容器對象,組織單位可包含其它各類對象,包括其它組織單元,如"tech");
cn(common name,公共名稱,如"ThomasJohansson");
sn(surname,姓,如"Johnsson");
dn(distinguished name,惟一辨別名,相似LinuxFS的絕對路徑,每一個對象都有一個惟一的名稱,如"uid=tom,ou=market,dc=example,dc=com",在一個目錄樹中,dn老是惟一的,它是一個識別屬性,一般用於檢索,至關於關係DB表中的primary key);
rdn(relative dn,相對辨別名,相似於LinuxFS的相對路徑,它是與目錄樹結構無關的部分,如"uid=tom"或"cn=Thomas Johasson");
c(country,國家,如"CN","US");
o(organization,組織名,如"Example,Inc.");
dn的兩種設置:
基於cn,最多見的cn是從/etc/group轉來的條目,例如:cn=test,ou-auth,dc=example,dc=org;
基於uid,最多見的uid是從/etc/passwd轉來的條目,例如:uid=test,ou=auth,dc=example,dc=org;
LDAP目錄服務的特色:
LDAP是一個跨平臺的、標準的協議,近年來獲得業界普遍承認;
LDAP的結構用樹形結構來表示,而不是用表格,所以不用SQL語句維護;
LDAP提供了靜態數據的快速查詢方式,但在寫數據方面並不擅長;
LDAP服務可以使用基於push或pull的複製信息技術,用簡單的或基於安全證書的安全認證,複製部分或所有數據,既保證了數據的安全性又提升了數據的訪問效率;
LDAP是一個安全的協議,LDAPv3支持SASL(simpleauthentication and security layer)、SSL(secure socket layer)和TLS(transport layer security),使用認證來確保事務的安全,另LDAP提供了不一樣層次的訪問控制,以限制不一樣用戶的訪問權限;
LDAP支持異類數據存儲,存儲的數據能夠是文本資料、二進制圖片等;
LDAP是C/S模型,server用於存儲樹,client提供操做目錄信息樹的工具,經過這些工具可將數據庫的內容以文本格式LDIF(LDAP data interchange format)呈如今咱們面前;
LDAP是一種開放internet標準,LDAP協議是跨平臺的internet協議,它是基於X.500標準的,與X.500不一樣,LDAP支持tcp/ip便可以分佈式部署;
LDIF,LDAP datainterchange format,LDAP數據交換格式,用於LDAP數據導入、導出的格式,它是LDAP數據庫信息的一種文本格式,一種ASCII文件格式,用來交換數據並使得在LDAP server間交換數據成爲可能,LDIF文件最經常使用的功能是向目錄導入或修改信息,這些信息的格式需按照LDAP中架構schema格式組織,若不符合其要求的格式就會出現錯誤;
LDIF文件的特色:
經過空行來分割或定義一個條目;
以#開始的行爲註釋;
全部屬性的賦值方法爲:屬性:屬性值,如dn:dc=……,dc=……;
屬性能夠被重複賦值;
每行的結尾不容許有空格;
注:LDAP的每條記錄中必須包含一個objectClass屬性,且需賦值至少一個值,objectClass屬性有等級之分,屬性至關於變量,它能夠被自定義賦值,值不能相同
LDAP的目錄結構:
LDAP目錄服務是經過目錄數據庫來存儲網絡信息來提供目錄服務的,爲方便用戶迅速查找和定位信息,目錄數據庫是以目錄信息樹DIT(directory information tree)爲存儲方式的樹形存儲結構,DIT及其相關概念構成了LDAP協議的信息模型;
在LDAP中,目錄是按照樹形結構組織,DIT是一個主要進行讀操做的數據庫;
DIT由entry條目組成,entry至關於關係DB中的表中的記錄record;
entry是具備dn的attribute-value(屬性-值對)的集合;
在Linux FS中,最頂層是root根,LDAP也用root做根,稱爲BaseDN(LDAP目錄的最頂部根);
因爲X.500歷史緣由,LDAP目錄用ou從邏輯上把數據分開,ou也是一種entry(容器條目),ou下便是真正的用戶條目;
什麼樣的信息可存儲在目錄當中:
LDAP的信息模型基於entry,一個條目就是一些具備全局惟一的標識名稱,dn的屬性集合,dn用於無二義性的指代一個惟一的條目,條目的每個屬性都有一個type,一個或多個value,type每每是特定字符串的簡寫,如用cn指代common name,或用mail指代電子郵件地址,value的語法依賴於type,好比,type爲cn的屬性可能包含值Babs Jensen,type爲mail的屬性可能包含值babs@example.org,type爲jpeg photo的屬性可能包含二進制格式的JPEG圖像;
LDAP容許經過使用objectClass的特殊屬性或控制哪些屬性是條目所必須的,哪些屬性是條目可選的,objectClass屬性的值是由條目所必須聽從的方案schema來定義的;
#ldapsearch -LLL -w oldboy -x -Hldap://10.0.0.8 -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "uid=*" #(經過此命令可取出數據庫中存儲的內容)
LDAP目錄邏輯結構原理(信息在目錄中是如何組織的):
在ldap中條目是按樹狀層次結構組織的,傳統上,這個結構每每是地理界限或組織界限的反映,表明國家的條目位於整個目錄樹的頂層,之下的條目則表明各個州及國家性的組織,再下面的條目表明着組織單位、我的、打印機、文件等,下圖是按傳統命名方式組織的ldap目錄信息樹;
目錄樹也可按照internet域名結構組織,由於它容許按DNS對目錄服務進行定位,這種命名方式正變得愈來愈受歡迎,以下圖:
信息是如何被引用的?
一個條目是經過它的標識名來引用的,而標識名是由相對標識名rdn和它的父條目名連在一直構成的,好比上圖:在internet命名例子中,Barbara Jensen條目有相對標識名uid=babs和[絕對]標識名uid=babs,ou=People,dc=example,dc=com
注:通常用絕對標識名,完整dn格式在RFC2253中描述
信息是如何被訪問的?
LDAP定義了一組查詢和更新目錄的操做,支持的操做包括從目錄中添加和刪除條目,更改已有的條目及名字,大多數狀況,LDAP是用於搜索目錄中的信息的,經過指定搜索過濾器,LDAP可在目錄的相關部分搜索相符的條目,知足過濾條件的每個條目都能收到請求信息;
好比,要搜索位於st=California,c=US子樹之下且名稱中有Acme字符串且有一個傳真號的組織的條目,LDAP可輕鬆完成;要搜索位於dc=example,dc=com目錄子樹下的叫Barbara Jensen的人的條目並獲取找到的每一個條目的email地址,LDAP也可輕鬆完成;
怎樣保護信息不受未經受權的訪問?
一些目錄服務不但提供保護、容許信息對任何人可見,LDAP提供了一套機制來對客戶進行身份確認,或讓客戶證實他擁有鏈接到服務器的身份,這對服務器進行全方位的訪問控制鋪平了道路,從而確保了服務器上所包含信息的安全,LDAP也支持privacy和integrity的安全服務
LDAP是怎樣工做的?
LDAP目錄服務是基於C/S模式的,一個或者多個LDAPserver包含着組成整個DIT的數據,client鏈接到server而且發出一個請求request,而後server要麼以answer回答予以迴應,要麼給出一個指針referral,客戶能夠經過此指針獲取到所需的數據(一般該指針是指向另外一個LDAP server),不管client連到哪一個LDAP server,它看到的都是同一個目錄視圖view,這是LDAP這類全局目錄服務的一個重要特徵
LDAP的4個重要配置模式:
基本的目錄查詢服務(重點),slapd只爲本地域提供目錄服務,不會以任何方式與別的目錄服務器交互;
目錄查詢代理服務(指針referral),帶有referral的本地目錄服務,相似DNS的轉發器(dnsmasq開源軟件),本地運行ldap server,並將配置成爲當客戶的請求走出本地域的處理能力時能返回一個指針,該指針指向一個具有處理客戶請求能力的更高級的服務器地址,你能夠本身運行這一服務,也可使用別人已經提供的;
異機複製數據(即主從同步),同步複製的目錄服務,slapd守護程序用來將主slapd上的改變傳播到一個或多個從屬的slapd上,簡單易用的同步複製目錄方案(inotify+ldap客戶端命令方案;定時任務+ldap客戶端命令方案);
分佈式目錄服務:
In this configuration, the local service is partitioned intosmaller services, each of which may be replicated, and glued together with superior and subordinatereferrals.
本地的服務被分割成爲多個更小的服務,每個均可能被複制,且經過指針referral將上級superior和下級subordinate粘合起來,在實際工做中,使用主從同步集羣較多,跨機房就是經過open***同步;
ldap+haproxy|nginx|heartbeat(集羣高可用,驗證時不跨機房);
LDAP服務的應用領域(ldap目錄服務適合那些須要從不一樣的地點讀取信息,可是對於不須要常常更新的業務信息最爲有用):
信息安全類(數字證書管理、受權管理、單點登陸);
科學計算類(DCE(distributed computing environment分佈式計算環境),UDDI(universaldescription discovery and integration統一描述、發現和集成協議));
網絡資源管理類(mail系統、DNS系統、網絡用戶管理、電話號碼簿);
電子政務資源管理類(內網組織信息服務、電子政務目錄體系、人口基礎庫、法人基礎庫);
注:經常使用ldap做爲公司全部員工帳號的基礎信息庫,如:郵件帳號、電腦登陸帳號、辦公平臺帳號、共享服務帳號、SVN帳號、***帳號、server帳號、無線網登陸帳號等公共帳號登陸信息庫,可理解爲企業的active directory,另ldap可與microsoft的active directory打通
www.openldap.org
2.3是rhel5系列的默認版本;2.4是rhel6系列的默認版本;
ldap服務對系統要求不高,如DELLR410配置足夠,生產場景應至少兩臺server作ldap不至於宕機,ldap若在公網上使用兩臺server均應有兩個網卡(分別用於WAN數據轉發和LAN數據轉發),若經過***作LAN的ldap僅一個網卡便可
準備環境:
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5(Santiago)
[root@localhost ~]# uname -r
2.6.32-431.el6.x86_64
[root@localhost ~]# uname -m
x86_64
注:rhel6經過vmware clone後,先用setup命令配置好IP、DNS,並在配置文件ifcfg-eth0中將HWMAC和UUID項刪除,再#> /etc/udev/rules.d/70-persistent-net.rules將此文件清空,最後重啓系統
[root@localhost ~]# mv /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.backup
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rz(上傳http://mirrors.163.com/.help/CentOS6-Base-163.repo此地址下載的CentOS6-Base-163.repo文件)
[root@localhost yum.repos.d]# sed -i 's/$releasever/6/g' CentOS6-Base-163.repo
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: product-id,refresh-packagekit, security, subscription-manager
This system is not registered to Red HatSubscription Management. You can use subscription-manager to register.
Cleaning repos: base extras updates
Cleaning up Everything
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: product-id,refresh-packagekit, security, subscription-manager
This system is not registered to Red HatSubscription Management. You can use subscription-manager to register.
base | 3.7 kB 00:00
base/group_gz | 226 kB 00:00
base/filelists_db ……
[root@localhost yum.repos.d]# sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
[root@localhost yum.repos.d]# grep keepcache /etc/yum.conf
keepcache=1
[root@localhost yum.repos.d]# cd
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]#service iptables stop
iptables: Setting chains to policy ACCEPT:filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]# ntpdate time.windows.com
19 Jul 00:38:12 ntpdate[27946]: adjust timeserver 40.69.40.157 offset -0.016416 sec
[root@localhost ~]# date
Tue Jul 19 00:38:15 PDT 2016
[root@localhost ~]# crontab -e
……
[root@localhost ~]# crontab -l
#time sync
*/5 * * * * /usr/sbin/ntpdatetime.windows.com &> /dev/null
[root@localhost ~]# echo "10.96.20.113 etiantian.org" >> /etc/hosts
[root@localhost ~]# tail -1 !$ #(生產環境下hosts文件的分發工做由分發工具完成)
tail -1 /etc/hosts
10.96.20.113 etiantian.org
[root@localhost ~]# ping etiantian.org
PING etiantian.org (10.96.20.113) 56(84)bytes of data.
64 bytes from etiantian.org (10.96.20.113):icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from etiantian.org (10.96.20.113):icmp_seq=2 ttl=64 time=0.021 ms
……
在master-side安裝openldap:
[root@localhost ~]# rpm -qa openldap
openldap-2.4.23-32.el6_4.1.x86_64
[root@localhost ~]# rpm -qa | grep openldap
openldap-2.4.23-32.el6_4.1.x86_64
openldap-devel-2.4.23-32.el6_4.1.x86_64
compat-openldap-2.3.43-2.el6.x86_64
[root@localhost ~]#yum -y install openldap openldap-*
……
Total download size: 4.1 M
Downloading Packages:
(1/6):openldap-2.4.40-12.el6.x86_64.rpm | 284 kB 00:00
(2/6):openldap-clients-2.4.40-12.el6.x86_64.rpm |165 kB 00:00
(3/6):openldap-devel-2.4.40-12.el6.x86_64.rpm | 1.1 MB 00:00
(4/6):openldap-servers-2.4.40-12.el6.x86_64.rpm |2.0 MB 00:00
(5/6):openldap-servers-sql-2.4.40-12.el6.x86_64.rpm | 140 kB 00:00
(6/6):unixODBC-2.2.14-14.el6.x86_64.rpm |378 kB 00:00
……
[root@localhost ~]# yum -y install nscdnss-pam-ldapd nss-* pcre pcre-* #(安裝nss-*時有報錯,將nss-*與其它軟件包分開安裝,緣由nss-softokn-freebl*衝突,先升級再安裝)
……
Protected multilib versions:nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 !=nss-softokn-freebl-3.14.3-9.el6.i686
Youcould try using --skip-broken to work around the problem
Youcould try running: rpm -Va --nofiles --nodigest
[root@localhost ~]# yum -y install nscd nss-pam-ldapd pcre pcre-*
……
Total download size: 25 M
Downloading Packages:
(1/12): glibc-2.12-1.192.el6.i686.rpm | 4.4 MB 00:00
(2/12):glibc-2.12-1.192.el6.x86_64.rpm |3.8 MB 00:03
(3/12):glibc-common-2.12-1.192.el6.x86_64.rpm | 14 MB 00:12
(4/12):glibc-devel-2.12-1.192.el6.x86_64.rpm |988 kB 00:00
(5/12):glibc-headers-2.12-1.192.el6.x86_64.rpm | 617 kB 00:00
(6/12): nscd-2.12-1.192.el6.x86_64.rpm | 230 kB 00:00
(7/12):nss-pam-ldapd-0.7.5-32.el6.x86_64.rpm | 153 kB 00:00
(8/12): pam_ldap-185-11.el6.x86_64.rpm | 88 kB 00:00
(9/12): pcre-7.8-7.el6.x86_64.rpm | 196 kB 00:00
(10/12): pcre-devel-7.8-7.el6.x86_64.rpm | 320 kB 00:00
(11/12):pcre-static-7.8-7.el6.x86_64.rpm | 83 kB 00:00
(12/12): tzdata-2016f-1.el6.noarch.rpm | 452 kB 00:00
……
[root@localhost ~]# yum -y update nss-softokn-freebl
……
Total download size: 1.1 M
Downloading Packages:
(1/9): nspr-4.11.0-1.el6.x86_64.rpm | 114 kB 00:00
(2/9):nspr-devel-4.11.0-1.el6.x86_64.rpm | 112 kB 00:00
(3/9):nss-softokn-3.14.3-23.3.el6_8.x86_64.rpm | 262 kB 00:00
(4/9):nss-softokn-devel-3.14.3-23.3.el6_8.x86_64.rpm | 14 kB 00:00
(5/9):nss-softokn-freebl-3.14.3-23.3.el6_8.i686.rpm | 157 kB 00:00
(6/9):nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64.rpm | 168 kB 00:00
(7/9):nss-softokn-freebl-devel-3.14.3-23.3.el6_8.x86_64.rpm | 140 kB 00:00
(8/9):nss-util-3.21.0-2.el6.x86_64.rpm | 67 kB 00:00
(9/9):nss-util-devel-3.21.0-2.el6.x86_64.rpm | 69 kB 00:00
……
[root@localhost ~]#yum -y install nss-*
……
Total download size: 1.6 M
Downloading Packages:
(1/5): nss-3.21.0-8.el6.x86_64.rpm | 859 kB 00:00
(2/5):nss-devel-3.21.0-8.el6.x86_64.rpm | 205 kB 00:00
(3/5):nss-pkcs11-devel-3.21.0-8.el6.x86_64.rpm | 104 kB 00:00
(4/5):nss-sysinit-3.21.0-8.el6.x86_64.rpm | 47 kB 00:00
(5/5):nss-tools-3.21.0-8.el6.x86_64.rpm | 437 kB 00:00
……
[root@localhost ~]# rpm -qa | grep openldap
openldap-servers-2.4.40-12.el6.x86_64
openldap-2.4.40-12.el6.x86_64
openldap-clients-2.4.40-12.el6.x86_64
compat-openldap-2.3.43-2.el6.x86_64
openldap-servers-sql-2.4.40-12.el6.x86_64
openldap-devel-2.4.40-12.el6.x86_64
在master-side配置openldap:
[root@localhost ~]# cd /etc/openldap/
[root@localhost openldap]# ll
total 20
drwxr-xr-x. 2 root root 4096 Jul 19 00:48certs
-rw-r-----. 1 root ldap 121 May 10 16:32 check_password.conf
-rw-r--r--. 1 root root 282 Mar 31 06:49 ldap.conf
drwxr-xr-x. 2 root root 4096 Jul 19 00:48schema
drwx------. 3 ldap ldap 4096 Jul 19 00:48slapd.d
注:2.3版本的配置文件在/etc/openldap/slapd.conf,2.4的配置文件/etc/openldap/slapd.d/slapd.conf,2.4也兼容2.3處的配置文件,在/etc/openldap/slapd.conf處編輯好後再用命令#slaptest-f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d從新生成2.4的配置文件)
[root@localhost openldap]# cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
[root@localhost openldap]# cp slapd.conf slapd.conf.ori
[root@etiantian openldap]# slap<TAB>
slapacl slapadd slapauth slapcat slapd slapdn slapindex slappasswd slapschema slaptest
注:
[root@localhost openldap]# slappasswd --help
slappasswd: invalid option -- '-'
Usage: slappasswd [options]
-c format crypt(3) salt format
-g generate random password
-h hash password scheme
-n omit trailing newline
-o <opt>[=val] specify an option with a(n optional) value
module-path=<pathspec>
module-load=<filename>
-s secret new password
-u generate RFC2307 values (default)
-v increase verbosity
-T file read file for new password
[root@localhost openldap]# slappasswd -s oldboy #(用-s指定生成密碼,也可直接用#slappasswd交互式生成密碼,oldboy即爲openldap默認管理員Manager的密碼,此處管理員已更改成admin)
{SSHA}hTALz9Z4+KSokCeQrLtVQbXBnQlzJ31c
[root@localhost openldap]# slappasswd -s oldboy | sed -e "s#{SSHA}#rootpw\t {SSHA}#g" >>/etc/openldap/slapd.conf #(生成密碼並加入到配置文件中)
[root@localhost openldap]# tail -1 !$
tail -1 /etc/openldap/slapd.conf
rootpw {SSHA}oN4m6ZMllYE/RGsP5AOe4WBsB85tRatJ
[root@localhost openldap]# vim slapd.conf #(從98行開始更改以下,將98行到108行的權限控制註釋掉,自定義配置權限以下;指定數據庫格式爲bdb,directory指定數據庫存儲路徑;suffix指定搜索的後綴;checkpoint設置把內存中的數據寫回數據文件的操做,每達到2048KB或10min執行一次;rootdn中的cn設置管理員用戶名;loglevel設置日誌級別,296=256+32+8(256(日誌鏈接|操做|結果);32(搜索過濾器處理);8(鏈接管理));cachesize設置ldap可緩存的記錄數;注意此配置文件中參數在文件中的前後次序不能隨意改變,空格和以#開頭的註釋行被忽略,若某一行以空格開頭則被認爲是續上一行內容,即便前一行是註釋信息)
------------------file modify start--------------
#database config
#access to *
#bydn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"manage
#by * none
# enable server status monitoring(cn=monitor)
#database monitor
#access to *
#bydn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"read
#by dn.exact="cn=Manager,dc=my-domain,dc=com" read
#by * none
access to *
by self write
by anonymous auth
by * read
database bdb
#suffix "dc=my-domain,dc=com"
suffix "dc=etiantian,dc=org"
#checkpoint 1024 15
checkpoint 2048 10
#rootdn "cn=Manager,dc=my-domain,dc=com"
rootdn "cn=admin,dc=etiantian,dc=org"
……
directory /var/lib/ldap
……
rootpw {SSHA}oN4m6ZMllYE/RGsP5AOe4WBsB85tRatJ
loglevel 296
cachesize 1000
-----------------file modify end------------------
[root@etiantian openldap]# diff slapd.conf.ori slapd.conf
……
[root@etiantian openldap]# egrep -v "#|^$" slapd.conf
-------------------file start---------------
include /etc/openldap/schema/corba.schema
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/duaconf.schema
include /etc/openldap/schema/dyngroup.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/java.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
allow bind_v2
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
TLSCACertificate Path /etc/openldap/certs
TLSCertificate File "\"OpenLDAPServer\""
TLSCertificate KeyFile/etc/openldap/certs/password
access to *
by self write
by anonymous auth
by * read
database bdb
suffix "dc=etiantian,dc=org"
checkpoint 204810
rootdn "cn=admin,dc=etiantian,dc=org"
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
rootpw {SSHA}oN4m6ZMllYE/RGsP5AOe4WBsB85tRatJ
loglevel 296
cachesize 1000
-------------------file end------------------
注:也可用腳本快速配置
sed -i 's#^suffix#suffix "dc=etiantian,dc=org"#g' slapd.conf
sed -i 's#^rootdn#rootdn "cn=admin,dc=etiantian,dc=org"#g' slapd.conf
cat >> /etc/slapd.conf << EOF
loglevel 296
cachesize 1000
checkpoint 2048 10
EOF
注:權限控制的另外一個案例(可生產環境用):
access to *
by self write
by dn.exact="uid=auth,ou-sysusers,dc=intra,dc=qq,dc=com" Peername.regex=127\.0\.0\.1write
by dn.subtree="ou=sysusers,dc=intra,dc=qq,dc=com" read
by anonymous auth
配置rsyslog記錄ldap服務日誌:
[root@etiantian openldap]# cp /etc/rsyslog.conf /etc/rsyslog.conf.ori.`date +%F%T`
[root@etiantian openldap]# ll /etc/rsyslog.conf*
-rw-r--r--. 1 root root 3167 Mar 31 06:46/etc/rsyslog.conf
-rw-r--r--. 1 root root 3167 Jul 24 19:38/etc/rsyslog.conf.ori.2016-07-2419:38:03
[root@etiantian openldap]# vim /etc/rsyslog.conf
[root@etiantian openldap]# echo "#record ldap.log by jowin 2016-07-24" >> /etc/rsyslog.conf
[root@etiantian openldap]# echo "local4.* /var/log/ldap.log" >> /etc/rsyslog.conf
[root@etiantian openldap]# tail -2/etc/rsyslog.conf
#record ldap.log by jowin 2016-07-24
local4.* /var/log/ldap.log
[root@etiantian openldap]# service rsyslog restart
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
配置ldap數據庫路徑:
[root@etiantian openldap]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
[root@etiantian openldap]# chown ldap.ldap /var/lib/ldap/DB_CONFIG
[root@etiantian openldap]# chmod 700 /var/lib/ldap/
[root@etiantian openldap]# ll !$
ll /var/lib/ldap/
total 4
-rw-r--r--. 1 ldap ldap 845 Jul 24 19:55DB_CONFIG
[root@etiantian openldap]# slaptest -u #(檢測配置是否成功)
config file testing succeeded
[root@etiantian openldap]# pwd
/etc/openldap
[root@etiantian openldap]# ll slapd.d/
total 8
drwx------. 3 ldap ldap 4096 Jul 19 00:48cn=config
-rw-------. 1 ldap ldap 1281 Jul 19 00:48cn=config.ldif
[root@etiantian openldap]# rm -rf /etc/openldap/slapd.d/* #(將此目錄下默認的配置文件刪除,使用/etc/openldap/slapd.conf從新生成2.4版本的配置文件,若不從新生成在ldapsearch時會報錯ldap_bind: Invalid credentials (49))
[root@etiantian openldap]# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d #(若此步驟生成時出錯,#chown -Rldap.ldap /var/lib/ldap,#chown -R ldap.ldap /etc/openldap/slapd.d/,在/var/lib/ldap/下運行#db_recover並刪除alock,啓動slapd再次生成)
579584fe bdb_monitor_db_open: monitoringdisabled; configure monitor database to enable
config file testing succeeded
[root@etiantian openldap]# chown -R ldap.ldap /etc/openldap/slapd.d/
[root@etiantian openldap]# service slapd start #(rhel6的OpenLDAP版本爲2.4.40,rhel5.8中的openldap版本啓動使用#service ldap start)
Starting slapd: [ OK ]
[root@etiantian openldap]# slapd -V
@(#) $OpenLDAP: slapd 2.4.40 (May 10 201623:30:49) $
mockbuild@worker1.bsys.centos.org:/builddir/build/BUILD/openldap-2.4.40/openldap-2.4.40/build-servers/servers/slapd
[root@etiantian openldap]# lsof -i :389 #(默認port389,ldaps加密後的port636)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
slapd 36097 ldap 7u IPv4 684359 0t0 TCP *:ldap (LISTEN)
slapd 36097 ldap 8u IPv6 684360 0t0 TCP *:ldap (LISTEN)
[root@etiantian openldap]# ps aux | grepldap
ldap 36097 0.0 7.3 498712 16780 ? Ssl 19:59 0:00 /usr/sbin/slapd-h ldap:/// ldapi:/// -u ldap
root 36125 0.0 0.3 103264 832 pts/0 S+ 20:03 0:00 grep ldap
[root@etiantian openldap]# chkconfig slapdon
[root@etiantian openldap]# chkconfig --listslapd
slapd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@etiantian openldap]# tail/var/log/ldap.log
……
[root@etiantian openldap]# rpm -q openldap-clients
openldap-clients-2.4.40-12.el6.x86_64
[root@etiantian openldap]# ldap<TAB>
ldapadd ldapcompare ldapdelete ldapexop ldapmodify ldapmodrdn ldappasswd ldapsearch ldapurl ldapwhoami
[root@etiantian openldap]# ldapsearch -LLL -W -x -H ldap://etiantian.org -D "cn=admin,dc=etiantian,dc=org" -b "dc=etiantian,dc=org" "(uid=*)" #(No such object表示數據庫沒有內容,正常)
Enter LDAP Password:
No such object (32)
在ldap-master中添加數據:
方1、編輯配置文件*.ldif並導入數據,此方法理解較複雜,但操做簡單,不適合初學者;
方2、根據系統用戶及ldap自帶的腳本初始化數據;
方3、經過ldap客戶端工具來初始化數據(此處是web程序);
舉例(方2):
[root@etiantian openldap]# yum -y install migrationtools
[root@etiantian openldap]# rpm -qlmigrationtools
……
/usr/share/migrationtools/migrate_common.ph
……
[root@etiantian openldap]# groupadd -g 5000 test
[root@etiantian openldap]# useradd -u 5000 -g 5000 test
[root@etiantian openldap]# echo test | passwd --stdin test
Changing password for user test.
passwd: all authentication tokens updatedsuccessfully.
[root@etiantian openldap]# grep test /etc/passwd > passwd.in
[root@etiantian openldap]# grep test /etc/group > group.in
[root@etiantian openldap]# cp/usr/share/migrationtools/migrate_common.ph/usr/share/migrationtools/migrate_common.ph.bakup
[root@etiantian openldap]# vim /usr/share/migrationtools/migrate_common.ph #(在71行處更改以下兩行信息)
#$DEFAULT_MAIL_DOMAIN ="padl.com";
$DEFAULT_MAIL_DOMAIN ="etiantian.org";
#$DEFAULT_BASE ="dc=padl,dc=com";
$DEFAULT_BASE ="dc=etiantian,dc=org";
[root@etiantian openldap]# echo $LC_ALL
[root@etiantian openldap]# export LC_ALL=C
[root@etiantian openldap]# cd/usr/share/migrationtools/
[root@etiantian migrationtools]# ./migrate_base.pl > base.ldif
[root@etiantian migrationtools]# ./migrate_passwd.pl /etc/openldap/passwd.in passwd.ldif
[root@etiantian migrationtools]# ./migrate_group.pl /etc/openldap/group.in group.ldif
[root@etiantian migrationtools]# ldapadd --help
usage: ldapadd [options]
Thelist of desired operations are read from stdin or from the file
specifiedby "-f file".
-f file read operations from `file'
-D binddn bind DN
-H URI LDAP Uniform Resource Identifier(s)
-w passwd bind password (for simple authentication)
-x Simple authentication
[root@etiantian migrationtools]# ldapadd -w oldboy -x -H ldap://127.0.0.1 -D "cn=admin,dc=etiantian,dc=org" -f base.ldif #(-w不交互直接指定密碼,相似mysql的-p)
adding new entry "dc=etiantian,dc=org"
adding new entry"ou=Hosts,dc=etiantian,dc=org"
adding new entry"ou=Rpc,dc=etiantian,dc=org"
adding new entry"ou=Services,dc=etiantian,dc=org"
adding new entry"nisMapName=netgroup.byuser,dc=etiantian,dc=org"
adding new entry "ou=Mounts,dc=etiantian,dc=org"
adding new entry"ou=Networks,dc=etiantian,dc=org"
adding new entry"ou=People,dc=etiantian,dc=org"
adding new entry"ou=Group,dc=etiantian,dc=org"
adding new entry"ou=Netgroup,dc=etiantian,dc=org"
adding new entry "ou=Protocols,dc=etiantian,dc=org"
adding new entry"ou=Aliases,dc=etiantian,dc=org"
adding new entry"nisMapName=netgroup.byhost,dc=etiantian,dc=org"
[root@etiantian migrationtools]# ldapadd -w oldboy -x -H ldap://127.0.0.1 -D "cn=admin,dc=etiantian,dc=org" -f passwd.ldif
adding new entry"uid=test,ou=People,dc=etiantian,dc=org"
[root@etiantian migrationtools]# ldapadd -w oldboy -x -H ldap://127.0.0.1 -D "cn=admin,dc=etiantian,dc=org" -f group.ldif
adding new entry"cn=test,ou=Group,dc=etiantian,dc=org"
[root@etiantian migrationtools]# ldapsearch -LLL -w oldboy -x -H ldap://etiantian.org -D "cn=admin,dc=etiantian,dc=org" -b "dc=etiantian,dc=org" #(查詢導入的結果)
……
[root@etiantian migrationtools]# ldapsearch -LLL -w oldboy -x -H ldap://etiantian.org -D "cn=admin,dc=etiantian,dc=org" -b "dc=etiantian,dc=org" > ldap-backup.ldif #(將查詢結果導出便是備份,最好將base和用戶分開存放)
[root@etiantian openldap]# ldapdelete -x -D "cn=admin,dc=etiantian,dc=org" -w oldboy "uid=test,ou=People,dc=etiantian,dc=org" #(使用ldapdelete可刪除ldapsearch查詢出的任一條目)
注:
[root@etiantian ~]# ldapsearch --help
ldapsearch: invalid option -- '-'
ldapsearch: unrecognized option --
usage: ldapsearch [options] [filter[attributes...]]
where:
filter RFC 4515 compliant LDAPsearch filter
attributes whitespace-separatedlist of attribute descriptions
which may include:
1.1 no attributes
* all user attributes
+ all operational attributes
Search options:
-LLL print responses in LDIFformat without comments
-h host LDAP server
-H URI LDAP Uniform ResourceIdentifier(s)
-x Simple authentication
-w passwd bind password (for simpleauthentication)
-D binddn bind DN
-b basedn base dn for search
爲ldap-master配置web管理接口:
http://www.ldap-account-manager.org/
ldap客戶端管理接口不少,有b/s架構的,有c/s架構的,現以b/s架構的ldap-accout-manager-3.7.tar.gz說明;
[root@etiantian openldap]# yum -y install httpd php php-ldap php-gd
[root@etiantian openldap]# rpm -q httpd php php-ldap php-gd
httpd-2.2.15-54.el6.centos.x86_64
php-5.3.3-47.el6.x86_64
php-ldap-5.3.3-47.el6.x86_64
php-gd-5.3.3-47.el6.x86_64
[root@etiantian openldap]# cd /var/www/html
[root@etiantian html]# rz -E
rz waiting to receive.
[root@etiantian html]# tar xf ldap-account-manager-3.7.tar.gz
[root@etiantian html]# mv ldap-account-manager-3.7 ldap
[root@etiantian html]# cd ldap/config
[root@etiantian config]# cp config.cfg.sample config.cfg
[root@etiantian config]# cp lam.conf_sample lam.conf
[root@etiantian config]# vim lam.conf
:%s/cn=Manager/cn=admin/g
:%s/dc=my-domain/dc=etiantian/g
:%s/dc=com/dc=org/g
[root@etiantian config]# chown -R apache.apache /var/www/html/ldap
[root@etiantian config]# service httpdrestart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
在win的瀏覽器上http://10.96.20.113/ldap
點擊右上角LAM configuration-->Edit server profiles或Edit generalsetting(此處密碼不是ldap管理員的密碼,而是client軟件的密碼默認爲lam)
點幫助後顯示以下
輸入密碼lam進入後,可設置以下信息,此處改語言爲中文,改進入此處密碼爲123456-->save
回到主頁,進入管理員admin,密碼oldboy(前面用slappasswd 命令生成的密碼)-->登陸-->創建(初始化ldap數據庫的域)
通過使用,發現360瀏覽器不能很好的支持此網頁程序(不能很友好的顯示,點新用戶無反應等),換google瀏覽器很好
點用戶-->新用戶-->在我的信息處,名字和姓都填user01-->點unix,輸入以下信息-->點設置密碼-->肯定-->保存
在server-side查詢,最後有剛添加的用戶:
[root@etiantian config]# ldapsearch -LLL -w oldboy -x -H ldap://etiantian.org -D "cn=admin,dc=etiantian,dc=org" -b "dc=etiantian,dc=org""(uid=*)"
dn: uid=test,ou=People,dc=etiantian,dc=org
uid: test
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword::e2NyeXB0fSQxJHB5ZVpmdUJXJHEuWFc2d3Q5T2FsNmQ2QkVGeW51OS4=
shadowLastChange: 17007
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 5000
gidNumber: 5000
homeDirectory: /home/test
dn:uid=user01,ou=People,dc=etiantian,dc=org
objectClass: posixAccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
loginShell: /bin/bash
cn: user01 user01
uidNumber: 10004
gidNumber: 5000
sn: user01
givenName: user01
userPassword::e1NTSEF9c0tMVGpDVGdPT0ROMzY2VHA1V0FTQ3dRV1B4a3ZrQkQ=
uid: user01
homeDirectory: /home/user01
案例:
配置SVN+SASL經過ldap進行身份驗證:
SASL(simpleauthentication and security layer,是一種用來擴充C/S模式驗證能力的機制,sasl是一個膠合庫glue,經過這個庫把應用層與形式多樣的認證系統整合在一塊兒,相似PAM,PAM是認證方式(決定什麼人可訪問什麼服務),而SASL是認證過程,側重於信任創建的過程,這個過程能夠調用PAM來創建信任關係,具體認證交給SASL庫,SASL會根據相應的認證機制來完成驗證功能,默認rhel環境會安裝cyrus-sasl包);
[root@etiantian ~]# rpm -qa sasl
[root@etiantian ~]# rpm -qa | grep sasl
cyrus-sasl-devel-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-plain-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-md5-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-lib-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-2.1.23-13.el6_3.1.x86_64
[root@etiantian ~]# yum -y install *sasl*
……
[root@etiantian ~]#saslauthd -v #(當前可用的密碼驗證方法)
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
[root@etiantian ~]# grep MECH /etc/sysconfig/saslauthd #(當前驗證方式爲pam)
MECH=pam
# Options sent to the saslauthd. If theMECH is other than "pam" uncomment the next line.
[root@etiantian ~]# sed -i 's#MECH=pam#MECH=shadow#g' /etc/sysconfig/saslauthd #(先更改成本地認證方式,並測試是否成功,再切換至ldap)
[root@etiantian ~]# grep MECH !$
grep MECH /etc/sysconfig/saslauthd
MECH=shadow
# Options sent to the saslauthd. If theMECH is other than "pam" uncomment the next line.
[root@etiantian ~]# service saslauthd restart
Stopping saslauthd: [FAILED]
Starting saslauthd: [ OK ]
[root@etiantian ~]# ps aux | grep saslauthd
root 38257 0.0 0.4 66384 960 ? Ss 03:39 0:00 /usr/sbin/saslauthd-m /var/run/saslauthd -a shadow
root 38259 0.0 0.3 66384 692 ? S 03:39 0:00 /usr/sbin/saslauthd-m /var/run/saslauthd -a shadow
root 38260 0.0 0.3 66384 692 ? S 03:39 0:00 /usr/sbin/saslauthd-m /var/run/saslauthd -a shadow
root 38261 0.0 0.3 66384 692 ? S 03:39 0:00 /usr/sbin/saslauthd-m /var/run/saslauthd -a shadow
root 38262 0.0 0.3 66384 692 ? S 03:39 0:00 /usr/sbin/saslauthd-m /var/run/saslauthd -a shadow
root 38264 0.0 0.2 6392 668 pts/0 S+ 03:39 0:00 grep saslauthd
[root@etiantian ~]# testsaslauthd -utest -ptest #(檢驗本地認證)
0: OK "Success."
[root@etiantian ~]# testsaslauthd -uuser01 -puser01 #(user01爲ldap用戶,認證失敗)
0: NO "authentication failed"
[root@etiantian ~]# grep user01 /etc/passwd
[root@etiantian ~]# grep test /etc/passwd
test:x:5000:5000::/home/test:/bin/bash
[root@etiantian ~]#sed -i 's#MECH=shadow#MECH=ldap#g' /etc/sysconfig/saslauthd
[root@etiantian ~]#grep 'MECH=' /etc/sysconfig/saslauthd
MECH=ldap
[root@etiantian ~]# man saslauthd #(搜索ldap,有以下幫助信息)
Authenticate against an ldap server. The ldap configuration parameters are readfrom /etc/saslauthd.conf. The location of this file can be changed withthe -O parameter. See the LDAP_SASLAUTHD file included with the distributionfor the list of available parameters.
[root@etiantian ~]# vim /etc/saslauthd.conf #(建立並編輯此文件)
ldap_servers:ldap://etiantian.org/
ldap_bind_dn:cn=admin,dc=etiantian,dc=org
ldap_bind_pw: oldboy
ldap_search_base:ou=People,dc=etiantian,dc=org
ldap_filter: uid=%U
ldap_password_attr:userPassword
[root@etiantian ~]# service saslauthd restart
Stopping saslauthd: [ OK ]
Starting saslauthd: [ OK ]
[root@etiantian ~]# testsaslauthd -uuser01 -puser01
0: OK "Success."
[root@etiantian ~]# testsaslauthd -utest -ptest
0: OK "Success."
安裝配置啓動SVN(詳見《二十一SVN》)
[root@etiantian ~]# svnserve -d -r/application/svndata/
[root@etiantian ~]# lsof -i :3690
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
svnserve 39169 root 3u IPv4 786445 0t0 TCP *:svn (LISTEN)
[root@etiantian ~]# vim /etc/sasl2/svn.conf #(編輯並建立此目錄下svn.conf文件)
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
[root@etiantian ~]# cd/application/svndata/sadoc/conf/
[root@etiantian conf]# vim svnserve.conf #(配置指定項目下的svnserve.conf該文件,使之使用sasl認證,注意打開的參數要頂格)
[sasl]
use-sasl = true
[root@etiantian conf]# vim /application/svnpasswd/authz #(要在svn的authz文件中受權,添加以下信息,使之可訪問svn中指定的項目,passwd文件中再也不須要添加用戶了由於走的是sasl認證)
[groups]
ldap_user = test,user01
[sadoc:/]
@ldap_user = rw
[/]
@ldap_user = r
[root@etiantian conf]# pkill svnserve
[root@etiantian conf]# lsof -i :3690
[root@etiantian conf]# svnserve -d -r /application/svndata
[root@etiantian conf]# lsof -i :3690
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
svnserve 39209 root 3u IPv4 789136 0t0 TCP *:svn (LISTEN)
[root@etiantian conf]# ll /tmp
total 24
drwx------. 2 chai chai 4096 Mar 30 22:52pulse-MUK7gfWor9cA
drwxrwxrwt. 2 root root 4096 Mar 31 06:51VMwareDnD
drwxr-xr-x. 3 root root 4096 Jul 13 20:43www
-rw-------. 1 root root 977 Jul 24 23:47yum_save_tx-2016-07-24-23-47dRJqm_.yumtx
-rw-------. 1 root root 4431 Jul 24 23:51yum_save_tx-2016-07-24-23-51LOK3bk.yumtx
[root@etiantian conf]# svn checkout svn://10.96.20.113/sadoc /tmp --username test --password test
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<svn://10.96.20.113:3690> fa820bcd-c61a-46d9-beed-a63b9ef0bbc6
can only be stored to diskunencrypted! You are advised toconfigure
your system so that Subversion can storepasswords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of thiswarning by setting the value
of the 'store-plaintext-passwords' optionto either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A /tmp/2.txt
A /tmp/b.txt
A /tmp/test2.txt
A /tmp/3.txt
A /tmp/c.txt
A /tmp/d.txt
A /tmp/rsync.txt
A /tmp/test.txt
A /tmp/1.txt
A /tmp/a.txt
Checked out revision 21.
[root@etiantian conf]# ll /tmp
total 24
-rw-r--r--. 1 root root 0 Jul 25 19:07 1.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 2.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 3.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 a.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 b.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 c.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 d.txt
drwx------. 2 chai chai 4096 Mar 30 22:52pulse-MUK7gfWor9cA
-rw-r--r--. 1 root root 0 Jul 25 19:07 rsync.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 test2.txt
-rw-r--r--. 1 root root 0 Jul 25 19:07 test.txt
drwxrwxrwt. 2 root root 4096 Mar 31 06:51VMwareDnD
drwxr-xr-x. 3 root root 4096 Jul 13 20:43www
-rw-------. 1 root root 977 Jul 24 23:47yum_save_tx-2016-07-24-23-47dRJqm_.yumtx
-rw-------. 1 root root 4431 Jul 24 23:51yum_save_tx-2016-07-24-23-51LOK3bk.yumtx
實現open***、samba、vsftpd、redmine、Mantis、httpd、git等應用軟件經過ldap權限認證;
實現acitve directory與ldap同步
補充svn,某公司網頁遊戲更新流程: