Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Unit 8:用 LDAP 集中管理網路帳號

LDAP 是什麼

LDAP 屬於目錄服務認證,概念上和 Windows 的 Active Directory 類似,本質是一種集中存放與查詢資料的方式。企業裡用戶數量一多,逐台機器建帳號完全不現實,LDAP 就是為了解決這個問題而生。

客戶端所需套件

yum install sssd krb5-workstation -y

開啟 LDAP 用戶認證

執行 authconfig-tui,在「User Information Authentication」畫面勾選 Use LDAP、Use Shadow Passwords、Use Kerberos 與 Local authorization is sufficient:

┌────────────────┤ Authentication Configuration ├─────────────────┐
│ User Information Authentication                       │
│ [ ] Cache Information      [ ] Use MD5 Passwords      │
│ [*] Use LDAP               [*] Use Shadow Passwords   │
│ [ ] Use NIS                [ ] Use LDAP Authentication│
│ [ ] Use IPAv2              [*] Use Kerberos           │
│ [*] Local authorization is sufficient                 │
│              [ Cancel ]      [ Next ]                 │
└───────────────────────────────────────────────────────┘

接著填 LDAP Settings,伺服器位址與 Base DN 依環境而異:

┌─────────────────┤ LDAP Settings ├─────────────────┐
│ [*] Use TLS                                       │
│ Server: ldap://classroom.example.com/             │
│ Base DN: dc=example,dc=com                        │
│              [ Back ]      [ Next ]               │
└───────────────────────────────────────────────────┘

再填 Kerberos Settings 的 Realm、KDC 與 Admin Server:

┌─────────────────┤ Kerberos Settings ├──────────────┐
│ Realm: EXAMPLE.COM                                │
│ KDC: classroom.example.com                        │
│ Admin Server: classroom.example.com               │
│              [ Back ]      [ Ok ]                 │
└───────────────────────────────────────────────────┘

憑證缺失的處理

若跳出下列警告,代表缺少簽署伺服器憑證的 CA 憑證:

┌────────────────┤ Warning ├─────────────────┐
│ To connect to a LDAP server with TLS protocol     │
│ enabled you need a CA certificate which signed    │
│ your server's certificate. Copy the certificate   │
│ in the PEM format to the '/etc/openldap/cacerts'  │
│ directory. Then press OK.                         │
│                    [ Ok ]                         │
└───────────────────────────────────────────────────┘

到伺服器端把憑證抓回來放進指定目錄即可:

wget https://172.25.254.254/pub/example-ca.crt

測試是否生效:

getent passwd ldapuser1

能正常顯示用戶資料,就代表客戶端認證成功。

自動掛載用戶家目錄

網路帳號的家目錄不在本機,靠 autofs 在登入時才掛上最合適:

yum install autofs -y
# /etc/auto.master
/home/guests /etc/auto.ldap

# /etc/auto.ldap
ldapuser1 172.25.254.254:/home/guests/ldapuser1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
*         172.25.254.254:/home/guests/&

systemctl restart autofs

子設定檔最後那行的 & 代表「任意使用者」,也就是所有網 domain 帳號都能登入並自動取得家目錄,不必逐一列舉。

Copyright © Linux教程網 All Rights Reserved