Red Hat Training

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

2.2. 使用 authconfig

authconfig 工具可帮助配置要用于用户凭据的数据存储,如 LDAP。在 Red Hat Enterprise Linux 中,authconfig 同时具有 GUI 和命令行选项来配置任何用户数据存储。authconfig 工具可将系统配置为使用特定服务 - SSSD、LDAP、NIS 或 Winbind - 用于其用户数据库,以及使用不同类型的身份验证机制。
重要
要配置身份管理系统,红帽建议使用 ipa-client-install 工具或 realmd 系统,而不是 authconfigauthconfig 工具有限且更灵活。如需更多信息,请参阅 第 2.1 节 “系统身份验证的身份管理工具”
以下三个 authconfig 工具可用于配置身份验证设置:
  • authconfig-gtk 提供完整的图形界面。
  • authconfig 为手动配置提供命令行界面。
  • authconfig-tui 提供基于文本的 UI。请注意,这个工具已弃用。
所有这些配置工具必须以 root 用户身份运行。

2.2.1. 使用 authconfig CLI 提示

authconfig 命令行工具根据传递给脚本的设置更新系统身份验证所需的所有配置文件和服务。除了通过 UI 设置更多身份和身份验证配置选项外,authconfig 工具也可用于创建备份和 kickstart 文件。
有关 authconfig 选项的完整列表,请查看帮助输出和 man page。
运行 authconfig 时需要记住一些问题:
  • 对于每个命令,请使用 --update--test 选项。命令需要其中一个选项才能成功运行。使用 --update 写入配置更改。test 选项 显示更改,但不将更改应用到配置。
    如果没有使用 --update 选项,则不会将更改写入系统配置文件。
  • 命令行可用于更新现有配置并设置新配置。因此,命令行不会强制将所需的属性用于给定调用(因为 命令可能正在更新其他完整的设置)。
    编辑身份验证配置时,请非常小心,确保配置完整准确。将身份验证设置更改为不完整或错误值可将用户锁定在系统之外。在使用 --update 选项写入前,使用 --test 选项确认设置正确。
  • 每个启用选项都有对应的 disable 选项。

2.2.2. 安装 authconfig UI

默认情况下,未安装 authconfig UI,但管理员对身份验证配置进行快速更改非常有用。
要安装 UI,请安装 authconfig-gtk 软件包。这对一些常见的系统软件包有依赖项,如 authconfig 命令行工具、Bash 和 Python。其中大多数默认安装。
[root@server ~]# yum install authconfig-gtk
Loaded plugins: langpacks, product-id, subscription-manager
Resolving Dependencies
--> Running transaction check
---> Package authconfig-gtk.x86_64 0:6.2.8-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch         Version            Repository           Size
================================================================================
Installing:
 authconfig-gtk       x86_64       6.2.8-8.el7        RHEL-Server       105 k

Transaction Summary
================================================================================
Install  1 Package

... 8< ...

2.2.3. 启动 authconfig UI

  1. 打开终端,再以 root 用户身份登录。
  2. 运行 system-config-authentication 命令。
重要
authconfig UI 关闭时,任何更改都会立即生效。
Authentication 对话框中有三个配置标签页:
  • 身份和身份验证,用于配置用作身份存储的资源(存储用户 ID 和对应凭证的数据仓库)。
  • 高级选项,它配置密码或证书以外的身份验证方法,如智能卡和指纹。
  • 密码选项,用于配置密码验证方法。

图 2.1. authconfig Window

authconfig Window

2.2.4. 测试身份验证设置

充分且正确配置了身份验证非常重要。否则,所有用户(甚至 root 用户)都可以被锁定在系统之外,或者某些用户被阻止。
test 选项 会针对每一种可能的身份和身份验证机制打印系统的所有身份验证配置。这会显示已启用的设置以及哪些区域被禁用。
测试 选项可以自行运行,以显示完整的、当前配置,或者可与 authconfig 命令一起使用来显示 配置是如何更改(实际上没有更改 )。这对于验证建议的验证设置是否完整且正确非常有用。
[root@server ~]# authconfig --test
caching is disabled
nss_files is always enabled
nss_compat is disabled
nss_db is disabled
nss_hesiod is disabled
 hesiod LHS = ""
 hesiod RHS = ""
nss_ldap is disabled
 LDAP+TLS is disabled
 LDAP server = ""
 LDAP base DN = ""
nss_nis is disabled
 NIS server = ""
 NIS domain = ""
nss_nisplus is disabled
nss_winbind is disabled
 SMB workgroup = "MYGROUP"
 SMB servers = ""
 SMB security = "user"
 SMB realm = ""
 Winbind template shell = "/bin/false"
 SMB idmap range = "16777216-33554431"
nss_sss is enabled by default
nss_wins is disabled
nss_mdns4_minimal is disabled
DNS preference over NSS or WINS is disabled
pam_unix is always enabled
 shadow passwords are enabled
 password hashing algorithm is sha512
pam_krb5 is disabled
 krb5 realm = "#"
 krb5 realm via dns is disabled
 krb5 kdc = ""
 krb5 kdc via dns is disabled
 krb5 admin server = ""
pam_ldap is disabled
 LDAP+TLS is disabled
 LDAP server = ""
 LDAP base DN = ""
 LDAP schema = "rfc2307"
pam_pkcs11 is disabled
 use only smartcard for login is disabled
 smartcard module = ""
 smartcard removal action = ""
pam_fprintd is disabled
pam_ecryptfs is disabled
pam_winbind is disabled
 SMB workgroup = "MYGROUP"
 SMB servers = ""
 SMB security = "user"
 SMB realm = ""
pam_sss is disabled by default
 credential caching in SSSD is enabled
 SSSD use instead of legacy services if possible is enabled
IPAv2 is disabled
IPAv2 domain was not joined
 IPAv2 server = ""
 IPAv2 realm = ""
 IPAv2 domain = ""
pam_pwquality is enabled (try_first_pass local_users_only retry=3 authtok_type=)
pam_passwdqc is disabled ()
pam_access is disabled ()
pam_mkhomedir or pam_oddjob_mkhomedir is disabled (umask=0077)
Always authorize local users is enabled ()
Authenticate system accounts against network services is disabled

2.2.5. 使用 authconfig保存和恢复配置

更改身份验证设置可能会产生问题。不正确的更改配置可能会错误地排除应具有访问权限的用户,可能会导致与身份存储的连接失败,甚至可能会锁定对系统的所有访问。
在编辑身份验证配置之前,强烈建议管理员备份所有配置文件。这通过 --savebackup 选项完成。
[root@server ~]# authconfig --savebackup=/backups/authconfigbackup20200701
身份验证配置可以使用 --restorebackup 选项及要使用的备份名称恢复到之前保存的任何版本。
[root@server ~]# authconfig --restorebackup=/backups/authconfigbackup20200701
当每次更改配置时,authconfig 命令都会保存自动备份。可以使用 --restorelastbackup 选项恢复最后的备份。
[root@server ~]# authconfig --restorelastbackup