***************************
***********ldap************
***************************
1.ldap是什麼
ldap目錄服務認證,和windows活動目錄類似,就是記錄數據的一種方式
2.ldap客戶端所需軟件
yum install sssd krb5-workstation -y
3.如何開啓ldap用戶認證
authconfig-tui
┌────────────────┤ Authentication Configuration ├─────────────────┐
│ │
│ User Information Authentication │
│ [ ] Cache Information [ ] Use MD5 Passwords │
│ [*] Use LDAP [*] Use Shadow Passwords │
│ [ ] Use NIS [ ] Use LDAP Authentication │
│ [ ] Use IPAv2 [*] Use Kerberos │
│ [ ] Use Winbind [ ] Use Fingerprint reader │
│ [ ] Use Winbind Authentication │
│ [*] Local authorization is sufficient │
│ │
│ ┌────────┐ ┌──────┐ │
│ │ Cancel │ │ Next │ │
│ └────────┘ └──────┘ │
│ │
│ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────┤ LDAP Settings ├─────────────────┐
│ │
│ [*] Use TLS │
│ Server: ldap://cla***oom.example.com/___________ │
│ Base DN: dc=example,dc=com_______________________ │
│ │
│ ┌──────┐ ┌──────┐ │
│ │ Back │ │ Next │ │
│ └──────┘ └──────┘ │
│ │
│ │
└───────────────────────────────────────────────────┘
┌─────────────────┤ Kerberos Settings ├──────────────────┐
│ │
│ Realm: EXAMPLE.COM_____________________________ │
│ KDC: cla***oom.example.com___________________ │
│ Admin Server: cla***oom.example.com___________________ │
│ [ ] Use DNS to resolve hosts to realms │
│ [ ] Use DNS to locate KDCs for realms │
│ │
│ ┌──────┐ ┌────┐ │
│ │ Back │ │ Ok │ │
│ └──────┘ └────┘ │
│ │
│ │
└────────────────────────────────────────────────────────┘
【補圖】
如果有提示證書文件缺失的話,是因爲tls的證書缺失,需要到服務器端下載所需要的證書到/etc/openldap/cacerts,
用到的命令
wget http://172.25.254.254/pub/example-ca.crt
<測試>
getent passwd ldapuser1
如果用戶信息可以正常顯示,證明客戶端認證成功。
列出所有用戶
vim /etc/sssd/sssd.conf
enumerate = True
4.自動掛載用戶家目錄
yum install autofs -y
vim /etc/auto.master
/home/guests/etc/auto.ldap
vim /etc/auto.ldap
ldapuser1172.25.254.254:/home/guests/ldapuser1
————————————————————————————————————————————————————————
*172.25.254.254:/home/guests/&
systemctl restart autofs
systemctl enable autofs
5.【在新的機子上執行腳本獲得上述所有功能,腳本如下】
#!/bin/bash
echo "install software ing ..."
yum install sssd krb5-workstation autofs -y &>/dev/null
echo "config ldap auth client ing ..."
authconfig \
--enableldap \
--enablekrb5 \
--disableldapauth \
--enableldaptls \
--ldaploadcacert=http://172.25.254.254/pub/example-ca.crt \
--ldapserver="cla***oom.example.com" \
--ldapbasedn="dc=example,dc=com" \
--krb5realm="EXAMPLE.COM" \
--krb5kdc="cla***oom.example.com" \
--krb5adminserver="cla***oom.example.com" \
--enablesssd \
--enablesssdauth \
--update
echo "config ldap user\'s home dirctory ing ..."
echo /home/guests /etc/auto.ldap >> /etc/auto.master
echo "* 172.25.254.254:/home/guests/&" >> /etc/auto.ldap
systemctl restart autofs
systemctl enable autofs &> /dev/null
echo " All is Successfully !!!"
*******查詢authconfig命令內容*****
authconfig --help | less