使用 LDAP 服务器进行网络身份验证
- 下边介绍如何将计算机设置为客户端 , 以使用现有 LDAP 目录服务提供的网络用户账户。这样 , LDAP 目录就成为我们组织中所有网络用户和组的中心机构
- 用户账户信息可以确定装户的特征和配置。身份验证方式用于确定尝试登录的人员是否应该获得对账户的使用权限。网络目录服务可以提供用户账户信息和身份验证方法
LDAP 目录服务器可以用作分布式、集中式、网络用户管理服务。目录条目按树结构排列 , 可以在其中进行搜索。基础 DN ( 区分名称 ) 是树的基础 , 用于搜索用户和组的目录条目
LDAP 客户端配置的主要元素
– 1. 服务器的完全限定主机名
– 2. 基础 DN , 用于搜索用户定义
– 3. 认证机构 (“ CA” ) 证书 , 用于签署 LDAP 服务器的 SSL 证书
在配置这个时,需要重置虚拟机,并且更改yum源,过程如下
[root@desktop20 ~]# vim /etc/yum.repos.d/rhel_dvd.repo
[root@server20 ~]# cat /etc/yum.repos.d/rhel_dvd.repo
# Created by cloud-init on Thu, 10 Jul 2014 22:19:11 +0000
[rhel_dvd]
gpgcheck = 0
enabled = 1
baseurl = http://172.25.20.254/content/rhel7 (20为我的主机ip,测试时需要填自己ip)
name = Remote classroom copy of dvd
安装客户端软件
• authconfig-gtk
• sssd
• krb5-workstation
通过 authconfig-gtk 认证 ldap 用户
检测 ldap 认证用户
• getent passwd ldapuserx
• vim /etc/sssd.conf
– enumerate = ture | false
– systemctl restart sssd
通过 authconfig-tui 认证 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://classroom.example.com/___________ │
│ Base DN: dc=example,dc=com_______________________ │
│ │
│ ┌──────┐ ┌──────┐ │
│ │ Back │ │ Next │ │
│ └──────┘ └──────┘ │
│ │
│ │
└───────────────────────────────────────────────────┘ ┌─────────────────┤ Kerberos Settings ├──────────────────┐
│ │
│ Realm: EXAMPLE.COM_____________________________ │
│ KDC: classroom.example.com___________________ │
│ Admin Server: classroom.example.com___________________ │
│ [ ] Use DNS to resolve hosts to realms │
│ [ ] Use DNS to locate KDCs for realms │
│ │
│ ┌──────┐ ┌────┐ │
│ │ Back │ │ Ok │ │
│ └──────┘ └────┘ │
│ │
│ │
└────────────────────────────────────────────────────────┘
<当出现以下报错时>
┌────────────────┤ 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 │ │
│ └────┘ │
│ │
│ │
└────────────────────────────────────────────┘
这是因为tls的证书缺失,需要到服务器端下载所需要的证书到/etc/openldap/cacerts,
用到的命令
wget http://172.25.254.254/pub/example-ca.crt
<测试>
getent passwd ldapuser1
如果用户信息可以正常显示,证明客户端认成功。
下载证书文件
• cd /etc/openldap/cacerts
• wget http://classroom.example.com/pub/example-ca.crt
• ls /etc/openldap/cacerts
自动挂在 ldap 用户家目录
• 安装 autofs
• 编辑 autofs 策略文件
yum install autofs -y
vim /etc/autofs.master
/home/guests /etc/auto.ldap
vim /etc/auto.ldap
ldapuser1 172.25.254.254:/home/guests/ldapuser1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
* 172.25.254.254:/home/guests/&
systemctl restart autofs
systemctl enable autofs