20.4. 将 autofs 配置为使用 ldap 存储和检索自动挂载映射


您可以配置 autofs 服务,以检索存储在 LDAP 目录中的自动挂载映射。

先决条件

  • 已安装 autofsopenldap 软件包。
  • 为安全身份验证运行支持 Kerberos 的服务。

流程

  1. 要配置 LDAP 访问,请修改 /etc/openldap/ldap.conf 文件。确保设置了 BASEURI 选项,以反映适当的服务器和用于查找自动挂载条目的基础。
  2. /etc/autofs.conf 文件中,为自动挂载映射配置 LDAP 模式。默认情况下,autofs 将按配置文件中指定的顺序检查常用的模式:

    #
    # Define the LDAP schema to used for lookups
    #
    # If no schema is set autofs will check each of the schemas
    # below in the order given to try and locate an appropriate
    # basdn for lookups. If you want to minimize the number of
    # queries to the server set the values here.
    #
    #map_object_class = nisMap
    #entry_object_class = nisObject
    #map_attribute = nisMapName
    #entry_attribute = cn
    #value_attribute = nisMapEntry
    #
    # Other common LDAP naming
    #
    #map_object_class = automountMap
    #entry_object_class = automount
    #map_attribute = ou
    #entry_attribute = cn
    #value_attribute = automountInformation
    #
    #map_object_class = automountMap
    #entry_object_class = automount
    #map_attribute = automountMapName
    #entry_attribute = automountKey
    #value_attribute = automountInformation
    Copy to Clipboard Toggle word wrap
    注意

    您还可以将这些值明确设置为边缘减少 LDAP 查询。您可以在 /etc/autofs.conf 文件中以小写和大写形式编写属性。

  3. rfc2307bis 草案中描述了最近建立的用于在 LDAP 中存储自动映射的模式。要使用此模式,请通过取消注释并为 ldap_schema 选项设置适当的值,在 /etc/autofs.conf 文件中配置它。例如,如果您使用非标准模式,或需要覆盖默认行为,您可以在 /etc/autofs.conf 文件中指定相关的模式属性。以下值与常用的模式设置对应,如 rfc2307bis 草案中的设置:

    default_map_object_class = automountMap
    default_entry_object_class = automount
    default_map_attribute = automountMapName
    default_entry_attribute = automountKey
    default_value_atrribute = automountInformation
    Copy to Clipboard Toggle word wrap

    请注意,autofs 会自动检测标准模式,并且指定这些设置通常在自定义或混合架构环境中是必需的。如果使用,则仅应激活一组完整的架构定义。

  4. 如果您选择在配置中指定自定义模式,请确保只有一个与模式相关的条目集合处于活跃状态。注释掉任何其他内容以避免冲突。在 rfc2307bis 模式中,automountKey 属性替换了旧的 rfc2307 模式中使用的 cn 属性。以下是对应的 LDAP 数据交换格式(LDIF)配置示例:

    # auto.master, example.com
    dn: automountMapName=auto.master,dc=example,dc=com
    objectClass: top
    objectClass: automountMap
    automountMapName: auto.master
    
    # /home, auto.master, example.com
    dn: automountMapName=auto.master,dc=example,dc=com
    objectClass: automount
    automountKey: /home
    automountInformation: auto.home
    
    # auto.home, example.com
    dn: automountMapName=auto.home,dc=example,dc=com
    objectClass: automountMap
    automountMapName: auto.home
    
    # foo, auto.home, example.com
    dn: automountKey=foo,automountMapName=auto.home,dc=example,dc=com
    objectClass: automount
    automountKey: foo
    automountInformation: filer.example.com:/export/foo
    
    # /, auto.home, example.com
    dn: automountKey=/,automountMapName=auto.home,dc=example,dc=com
    objectClass: automount
    automountKey: /
    automountInformation: filer.example.com:/export/&
    Copy to Clipboard Toggle word wrap
  5. 要允许 LDAP 服务器进行身份验证,请编辑 /etc/autofs_ldap_auth.conf 文件:

    1. authrequired 更改为 yes。
    2. 将主体设置为 LDAP 服务器 host/FQDN@REALM 的 Kerberos 主机主体。主体名称用于连接目录,作为 GSS 客户端身份验证的一部分:

      <autofs_ldap_sasl_conf
           usetls="no"
           tlsrequired="no"
           authrequired="yes"
           authtype="GSSAPI"
      clientprinc="host/server.example.com@EXAMPLE.COM"/>
           secret="<ldap password>"/>
      Copy to Clipboard Toggle word wrap

      有关主机主体的更多信息,请参阅在 在 IdM 中使用规范化的 DNS 主机名。您还可以运行 klist -k 来获取确切的主机主体信息。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat