在RHEL 7上设置LDAP和Kerberos客户端身份验证(使用nslcd)
时间:2020-03-21 11:49:56 来源:igfitidea点击:
我们将配置RHEL 7系统以使用LDAP/Kerberos对FreeIPA进行身份验证。
准备工作
要使Kerberos运行,必须运行NTP同步和DNS解析。
我们将使用之前设置的FreeIPA服务器。
查看这篇文章,了解如何在RHEL 7上设置FreeIPA服务器。
配置LDAP认证
我们使用将SELinux设置为强制模式的RHEL 7.0服务器(指令也在RHEL 7.2上进行了测试)。
DNS配置为指向FreeIPA服务器:
# cat /etc/resolv.conf search rhce.local nameserver 10.8.8.70
# host 10.8.8.70 70.8.8.10.in-addr.arpa domain name pointer ipa.rhce.local.
安装
# yum install -y nscd nss-pam-ldapd wget
将CA证书从IPA服务器下载到我们的本地服务器:
# mkdir /etc/openldap/cacerts # wget -P /etc/openldap/cacerts/ftp://ipa.rhce.local/pub/cacert.p12
配置
这些是默认设置,请不要更改任何内容:
# egrep -i "sssd|lega" /etc/sysconfig/authconfig USESSSDAUTH=no FORCELEGACY=no USESSSD=yes
确保已启用nslcd服务:
# systemctl enable nslcd
在文本模式下运行authconfig:
# authconfig-tui
在“用户信息”中,选择“使用LDAP”,然后在“身份验证”下,选择“使用LDAP身份验证”。
在“ LDAP设置”屏幕中,选择“使用TLS”并指定以下内容:
Server: ipa.rhce.local Base DN: dc=rhce,dc=local
打开“ /etc/nslcd.conf”并添加以下行以允许使用自签名证书:
tls_reqcert never
重新启动nslcd服务:
# systemctl restart nslcd
通过使用LDAP用户登录进行验证:
# su - alice su: warning: cannot change directory to /home/alice: No such file or directory $id uid=1219400005(alice) gid=1219400005(alice) groups=1219400005(alice) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
配置Kerberos身份验证
安装
# yum install -y pam_krb5 krb5-workstation
配置
我发现从头开始配置Kerberos身份验证时,擦除文件的'/etc/krb5.conf'内容会有所帮助:
# > /etc/krb5.conf
在文本模式下运行authconfig:
# authconfig-tui
在“身份验证配置”屏幕上的“身份验证”下,选择“使用Kerberos”以启用Kerberos授权。
在“ LDAP设置”屏幕中,请勿进行任何更改。
在“ Kerberos设置”屏幕中,指定以下内容:
Realm: RHCE.LOCAL KDC: ipa.rhce.local Admin Server: ipa.rhce.local
为Kerberos alice用户获取Kerberos票证:
# kinit alice
验证票证:
# klist Ticket cache: FILE:/tmp/krb5cc_0 Default principal: Hyman@theitroad Valid starting Expires Service principal 07/05/16 11:21:27 08/05/16 11:21:25 krbtgt/Hyman@theitroad
这些仅供参考。
# cat /etc/krb5.conf [libdefaults] default_realm = RHCE.LOCAL dns_lookup_realm = false dns_lookup_kdc = false [realms] RHCE.LOCAL = { kdc = ipa.rhce.local admin_server = ipa.rhce.local } [domain_realm] rhce.local = RHCE.LOCAL .rhce.local = RHCE.LOCAL
测试Kerberos配置
# su - alice su: warning: cannot change directory to /home/alice: No such file or directory
$hostname srv1.rhce.local
$kinit Password for Hyman@theitroad:
$klist Ticket cache: FILE:/tmp/krb5cc_1219400005 Default principal: Hyman@theitroad Valid starting Expires Service principal 07/05/16 11:25:26 08/05/16 11:25:23 krbtgt/Hyman@theitroad
我们应该能够重新连接而无需提供任何密码:
$ssh ipa.rhce.local Could not create directory '/home/alice/.ssh'. [...] Could not chdir to home directory /home/alice: No such file or directory
$hostname ipa.rhce.local