Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
34.2. 配置自动挂载
在身份管理中,配置自动挂载条目(如位置和映射)需要现有的 autofs/NFS 服务器。创建自动挂载条目不会创建底层
autofs
配置。autofs
可以使用 LDAP 或 SSSD 作为数据存储手动配置,也可以自动配置。
注意
在更改自动挂载配置前,请测试至少一个用户,可以成功从命令行挂载其
/home
目录。确保 NFS 正常工作,以便稍后对潜在的 IdM 自动挂载配置错误进行故障排除。
34.2.1. 自动配置 NFS
在将系统配置为 IdM 客户端后,其中包含配置为域客户端一部分的 IdM 服务器和副本,可将
autofs
配置为使用 IdM 域作为其 NFS 域,并启用 autofs
服务。
默认情况下,ipa-client-automount 工具自动配置 NFS 配置文件
/etc/sysconfig/nfs
和 /etc/idmapd.conf
。它还将 SSSD 配置为管理 NFS 的凭据。如果 ipa-client-automount 命令不带任何选项运行,它会运行 DNS 发现扫描来识别可用的 IdM 服务器,并创建一个名为 default
的默认位置。
[root@ipa-server ~]# ipa-client-automount Searching for IPA server... IPA server: DNS discovery Location: default Continue to configure the system with these values? [no]: yes Configured /etc/nsswitch.conf Configured /etc/sysconfig/nfs Configured /etc/idmapd.conf Started rpcidmapd Started rpcgssd Restarting sssd, waiting for it to become available. Started autofs
可以使用 IdM 服务器并创建一个自动挂载位置,而不是默认位置:
[root@server ~]# ipa-client-automount --server=ipaserver.example.com --location=boston
除了设置 NFS 外,ipa-client-automount 工具将 SSSD 配置为缓存自动挂载映射,以防外部 IdM 存储无法访问。配置 SSSD 有两个方面:
- 它将服务配置信息添加到 SSSD 配置中。IdM 域条目被授予 autofs 提供程序和挂载位置的设置。
autofs_provider = ipa ipa_automount_location = default
NFS 被添加到支持的服务列表中(服务 = nss、pam、autofs...)并给出空白配置条目([autofs])。 - Name Service Switch(NSS)服务信息已更新,以首先检查 SSSD 是否有自动挂载信息,然后再检查本地文件。
automount: sss files
可能存在一些实例,如高安全性环境,客户端不适合缓存自动挂载映射。在这种情况下,ipa-client-automount 命令可以使用
--no-sssd
选项运行,该选项会更改所有必需的 NFS 配置文件,但不会更改 SSSD 配置。
[root@server ~]# ipa-client-automount --no-sssd
如果使用
--no-sssd
,由 ipa-client-automount 更新的配置文件列表会有所不同:
- 该命令更新
/etc/sysconfig/autofs
,而不是/etc/sysconfig/nfs
。 - 命令使用 IdM LDAP 配置
/etc/autofs_ldap_auth.conf
。 - 命令将
/etc/nsswitch.conf
配置为使用 LDAP 服务进行自动挂载映射。
注意
ipa-client-automount 命令只能运行一次。如果配置中存在错误,需要手动编辑配置文件。
34.2.2. 手动配置 autofs 以使用 SSSD 和身份管理
- 编辑
/etc/sysconfig/autofs
文件,以指定 autofs 搜索的模式属性:# # Other common LDAP naming # MAP_OBJECT_CLASS="automountMap" ENTRY_OBJECT_CLASS="automount" MAP_ATTRIBUTE="automountMapName" ENTRY_ATTRIBUTE="automountKey" VALUE_ATTRIBUTE="automountInformation"
- 指定 LDAP 配置。执行此操作有两种方法:最简单的方法是让自动挂载服务自行发现 LDAP 服务器和位置:
LDAP_URI="ldap:///dc=example,dc=com"
或者,明确设置要使用的 LDAP 服务器,以及用于 LDAP 搜索的基本 DN:LDAP_URI="ldap://ipa.example.com" SEARCH_BASE="cn=location,cn=automount,dc=example,dc=com"
注意 - 编辑
/etc/autofs_ldap_auth.conf
文件,以便 autofs 允许客户端通过 IdM LDAP 服务器进行身份验证。- 将
authrequired
更改为 yes。 - 将 NFS 客户端服务器的 Kerberos 主机主体设置为 host/fqdn@REALM。主体名称用于连接 IdM 目录,来作为 GSS 客户端身份验证的一部分。
<autofs_ldap_sasl_conf usetls="no" tlsrequired="no" authrequired="yes" authtype="GSSAPI" clientprinc="host/server.example.com@EXAMPLE.COM" />
如有必要,请运行 klist -k 来获取确切的主机主体信息。 - 将 autofs 配置为 SSSD 管理的服务之一。
- 打开 SSSD 配置文件。
[root@server ~]# vim /etc/sssd/sssd.conf
- 将 autofs 服务添加到 SSSD 处理的服务列表中。
[sssd] services = nss,pam,
autofs
- 创建一个新的 [autofs] 部分。这可以留空;autofs 服务的默认设置可与大多数基础架构配合使用。
[nss] [pam] [sudo]
[autofs]
[ssh] [pac] - (可选)为 autofs 条目设置搜索基础。默认情况下,这是 LDAP 搜索库,但可以在
ldap_autofs_search_base
参数中指定子树。[domain/EXAMPLE] ... ldap_search_base = "dc=example,dc=com" ldap_autofs_search_base = "ou=automount,dc=example,dc=com"
- 重启 SSSD:
[root@server ~]# systemctl restart sssd.service
- 检查
/etc/nsswitch.conf
文件,以便 SSSD 被列为自动挂载配置的源:automount:
sss
files - 重启 autofs:
[root@server ~]# systemctl restart autofs.service
- 通过列出用户的
/home
目录来测试配置:[root@server ~]# ls /home/userName
如果这没有挂载远程文件系统,请检查/var/log/messages
文件是否有错误。如有必要,通过将LOGGING
参数设置为 debug 来提高/etc/sysconfig/autofs
文件中的debug
级别。
注意
如果自动挂载存在问题,则跨引用 IdM 实例的 389 目录服务器访问日志的自动挂载尝试,这将显示尝试的访问、用户和搜索基础。
还可以通过 debug 登录在前台运行自动挂载。
automount -f -d这将直接打印调试日志信息,而无需使用自动挂载的日志对 LDAP 访问日志进行交叉检查。
34.2.3. 在 Solaris 中配置自动挂载
注意
Solaris 对 autofs 配置使用不同的模式,与身份管理使用的架构不同。身份管理使用 2307bis 风格的自动挂载模式,该模式是为 389 目录服务器定义的(在 IdM 的内部目录服务器实例中使用)。
- 如果 NFS 服务器在 Red Hat Enterprise Linux 上运行,请在 NFSv3 的 Solaris 机器上指定最大支持版本。编辑
/etc/default/nfs
文件并设置以下参数:NFS_CLIENT_VERSMAX=3
- 使用 ldapclient 命令将主机配置为使用 LDAP:
ldapclient -v manual -a authenticationMethod=none -a defaultSearchBase=dc=example,dc=com -a defaultServerList=ipa.example.com -a serviceSearchDescriptor=passwd:cn=users,cn=accounts,dc=example,dc=com -a serviceSearchDescriptor=group:cn=groups,cn=compat,dc=example,dc=com -a serviceSearchDescriptor=auto_master:automountMapName=auto.master,cn=location,cn=automount,dc=example,dc=com?one -a serviceSearchDescriptor=auto_home:automountMapName=auto_home,cn=location,cn=automount,dc=example,dc=com?one -a objectClassMap=shadow:shadowAccount=posixAccount -a searchTimelimit=15 -a bindTimeLimit=5
- 启用 自动挂载 :
# svcadm enable svc:/system/filesystem/autofs
- 测试配置。
- 检查 LDAP 配置:
# ldapclient -l auto_master dn: automountkey=/home,automountmapname=auto.master,cn=location,cn=automount,dc=example,dc=com objectClass: automount objectClass: top automountKey: /home automountInformation: auto.home
- 列出用户的
/home
目录:# ls /home/userName