Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

5.3. IdM 命令行实用程序

IdM 的基本命令行脚本名为 ipaipa 脚本是多个子命令的父脚本。这些子命令随后用于管理 IdM。例如,ipa user-add 命令添加一个新用户:
$ ipa user-add user_name
与 UI 中的管理相比,命令行管理具有某些优势;例如,命令行实用程序允许以一致的方式自动执行和重复执行管理任务,而无需人工干预。此外,虽然大多数管理操作都从命令行和 Web UI 中可用,但某些任务只能从命令行执行。
注意
本节仅提供 ipa 子命令的一般信息。其它专用于 IdM 管理区域的部分提供了更多信息。例如,有关使用 ipa 子命令管理用户条目的详情,请参考 第 11 章 管理用户帐户

5.3.1. 获取 ipa 命令的帮助信息

ipa 脚本可以显示关于特定子命令的帮助信息: 主题。要显示可用主题列表,请使用 ipa help topics 命令:
$ ipa help topics

automember         Auto Membership Rule.
automount          Automount
caacl              Manage CA ACL rules.
...
要显示特定主题的帮助信息,请使用 ipa help topic_name 命令。例如,显示有关 自动成员 主题的信息:
$ ipa help automember

Auto Membership Rule.

Bring clarity to the membership of hosts and users by configuring inclusive
or exclusive regex patterns, you can automatically assign a new entries into
a group or hostgroup based upon attribute information.

...

EXAMPLES:

 Add the initial group or hostgroup:
   ipa hostgroup-add --desc="Web Servers" webservers
   ipa group-add --desc="Developers" devel
...
ipa 脚本还可以显示可用的 ipa 命令列表。要做到这一点,请使用 ipa help 命令
$ ipa help commands
automember-add                         Add an automember rule.
automember-add-condition               Add conditions to an automember rule.
...
有关单个 ipa 命令的详细帮助,请在命令中添加 --help 选项。例如:
$ ipa automember-add --help

Usage: ipa [global-options] automember-add AUTOMEMBER-RULE [options]

Add an automember rule.
Options:
  -h, --help            show this help message and exit
  --desc=STR            A description of this auto member rule
...
有关 ipa 工具程序的详情请参考 ipa(1) man page。

5.3.2. 设置值列表

IdM 在列表中存储条目属性。例如:
ipaUserSearchFields: uid,givenname,sn,telephonenumber,ou,title
对属性列表的任何更新都会覆盖上一个列表。例如,尝试通过仅指定此属性来添加单个属性,将之前定义的整个列表替换为单个新属性。因此,在更改属性列表时,您必须指定整个更新列表。
IdM 支持以下提供属性列表的方法:
  • 在同一命令调用中多次使用相同的命令行参数。例如:
    $ ipa permission-add --permissions=read --permissions=write --permissions=delete
  • 将列表括在大括号中,以允许 shell 进行扩展。例如:
    $ ipa permission-add --permissions={read,write,delete}

5.3.3. 使用特殊字符

当在包含特殊字符的 ipa 命令中传递命令行参数时,如 angle 括号(< 和 >)、ampersand (&)、星号或垂直栏(|),您必须使用反斜杠(\)转义这些字符。例如,要转义星号(*):
$ ipa certprofile-show certificate_profile --out=exported\*profile.cfg
包含未转义特殊字符的命令无法按预期工作,因为 shell 无法正确解析这些字符。

5.3.4. 搜索 IdM 条目

列出 IdM 条目

使用 ipa114-find 命令搜索特定类型的 IdM 条目。例如:
  • 要列出所有用户,请执行以下操作:
    $ ipa user-find
    ---------------
    4 users matched
    ---------------
      ...
  • 列出其指定属性包含 关键字的用户组
    $ ipa group-find keyword
    ----------------
    2 groups matched
    ----------------
      ...
    要配置属性 IdM 搜索用户和用户组,请参阅 第 13.5 节 “为用户和组设置搜索属性”
在搜索用户组时,您还可以将搜索结果限制为包含特定用户的组:
$ ipa group-find --user=user_name
您还可以搜索不包含特定用户的组:
$ ipa group-find --no-user=user_name

显示 entry Enicular Entry 的详情

使用 ipa *-show 命令显示特定 IdM 条目的详情。例如:
$ ipa host-show server.example.com
 Host name: server.example.com
 Principal name: host/server.example.com@EXAMPLE.COM
 ...

5.3.4.1. 调整搜索大小和时间限制

某些搜索结果(如查看用户列表)可能会返回大量条目。通过调整这些搜索操作,您可以在运行 ipa thefind 命令时提高整体服务器性能,如 ipa user-find,以及在 web UI 中显示对应的列表时。
搜索大小限制:
  • 定义从客户端、IdM 命令行工具或 IdM Web UI 发送到服务器的请求的最大条目数。
  • 默认值:100 个条目.
搜索时间限制:
  • 定义服务器等待搜索运行的最长时间。搜索达到此限制后,服务器将停止搜索并返回在该时间发现的条目。
  • 默认值:2 秒.
如果您将值设为 -1,IdM 在搜索时不会应用任何限制。
重要
如果设置的搜索大小或时间限制太大,则可能会对服务器性能造成负面影响。

Web UI:调整搜索大小和时间限制

为所有查询在全局范围内调整限制:
  1. 选择 IPA ServerConfiguration
  2. 搜索选项区域中设置所需的值。
  3. 点页面顶部的 Save

命令行:调整搜索大小和时间限制

要在全局范围内调整所有查询的限制,请使用 ipa config-mod 命令,并添加 --searchrecordslimit--searchtimelimit 选项。例如:
$ ipa config-mod --searchrecordslimit=500 --searchtimelimit=5
在命令行中,您还可以仅针对特定查询调整限值。为此,可在命令中添加 --sizelimit--timelimit 选项。例如:
$ ipa user-find --sizelimit=200 --timelimit=120
重要
请注意,使用带有 --searchrecordslimit 或 --searchtimelimit 选项的 ipa config-mod 命令调整大小或时间限制会影响 ipa命令返回的条目数量,如 ipa user-find
除了这些限制外,还会考虑在 Directory 服务器级别上配置的设置,并且可能会实施更严格的限制。有关目录服务器限制的更多信息,请参阅 红帽目录服务器管理指南