如何在 Rocky Linux 上安装 FreeIPA
在此页
- 先决条件
- 设置 FQDN
- 安装 FreeIPA 服务器包
- 配置 FreeIPA 服务器
- 设置防火墙
- 验证 Kerberos 管理员身份验证
- 登录到 FreeIPA 仪表板
- 结论
FreeIPA 是适用于 Linux/Unix 操作系统的免费开源身份管理解决方案。 RedHat身份管理系统的上游项目,为Linux/Unix系统提供身份验证和授权解决方案。
FreeIPA 建立在多个组件之上,包括目录服务器、DNS、Kerberos、PKI、Certmonger、NTP 服务器、Web 管理 UI 等。它提供了用户凭证和访问控制的集中来源。使用 FreeIPA 可以让管理员在集中的环境中轻松管理身份,还可以提供用户监控、身份验证和访问控制。
在本指南中,我们将向您展示如何在 Rocky Linux 服务器上安装 FreeIPA 身份管理器。
先决条件
- Linux 服务器 Rock Linux 8.5。
- 具有 sudo 管理员权限的非根用户。
设置 FQDN
首先,您将设置 Rocky Linux 服务器的 FQDN(完全限定域名)和 /etc/hosts 文件。
要设置服务器的 FQDN,请运行以下命令。在此示例中,我们使用 FQDN ipa.hwdomain.io。
sudo hostnamectl set-hostname ipa.hwdomain.io
现在使用 nano 编辑器编辑文件 /etc/hosts。
sudo nano /etc/hosts
输入详细服务器 IP 地址和服务器的 FQDN,如下所示。
192.168.10.25 ipa.hwdomain.io ipa
按 Ctrl+x 保存文件并输入 Y 确认并保存文件。
接下来,运行以下命令来验证 Rocky Linux 服务器的 FQDN。
hostname -f
您应该获得服务器 FQDN 的输出,例如 ipa.hwdomain.io。
最后,运行下面的 ping 命令以验证 FQDN 是否已解析为正确的服务器 IP 地址。
ping -c3 ipa.hwdomain.io
在下面的屏幕截图中,FQDN ipa.hwdomain.io 已解析并可通过 IP 地址 192.168.10.25 访问。

转到下一步以开始安装 FreeIPA。
安装 FreeIPA 服务器包
如果您已完成 FQDN 和 /etc/hosts 文件配置,您现在将向 Rocky Linux 系统安装 FreeIPA 包。
在 Rocky Linux 系统上,所有与 FreeIPA 相关的包都在模块 idm:DL1 上可用。您必须启用模块 idm:DL1 才能安装 FreeIPA 包。
运行以下命令以在 Rocky Linux 系统上启用 idm:DL1 模块。
sudo dnf module enable idm:DL1
输入 Y 确认并启用模块。

接下来,使用下面的 dnf 命令安装 FreeIPA 包。 ipa-server是FreeIPA的主包,ipa-server-dns是FreeIPA的附加包,提供DNS服务器功能。
sudo dnf install ipa-server ipa-server-dns -y
等待所有包安装,这将需要一些时间,具体取决于您的服务器连接。

完成所有安装后,转到下一步开始配置 FreeIPA 服务器。
配置 FreeIPA 服务器
现在您将在 Rocky Linux 系统上设置 FreeIPA 服务器。
在配置 FreeIPA 服务器之前,请确保您的服务器上的 IPv6 已启用并激活。当 IPv6 在内核空间上启用但在网络堆栈上不可用时,FreeIPA 服务器将自动检测错误。
检查您的服务器 IP 地址以验证 IPv6 在您的网络接口上可用。
sudo ip a
在下面的屏幕截图中,您将在输出中看到 inet6,这意味着 IPv6 在本地网络接口上可用,您已准备好设置 FreeIPA 服务器。

接下来,运行下面的 ipa-server-install 命令开始配置 FreeIPA 服务器。
sudo ipa-server-install --setup-dns --allow-zone-overlap
首先,您将看到有关设置 FreeIPA 服务器的操作的基本信息。
The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
This program will set up the IPA Server.
Version 4.9.6
This includes:
* Configure a stand-alone CA (dogtag) for certificate management
* Configure the NTP client (chronyd)
* Create and configure an instance of Directory Server
* Create and configure a Kerberos Key Distribution Center (KDC)
* Configure Apache (httpd)
* Configure DNS (bind)
* Configure SID generation
* Configure the KDC to enable PKINIT
FreeIPA 服务器将自动检测服务器 FQDN 并将其用作默认服务器主机名。按 ENTER 确认并继续。
To accept the default shown in brackets, press the Enter key.
Enter the fully qualified domain name of the computer
on which you're setting up server software. Using the form
<hostname>.<domainname>
Example: master.example.com.
Server host name [ipa.hwdomain.io]:
现在您需要为您的 FreeIPA 服务器设置域名。这将自动检测到,它基于服务器 FQDN。在此示例中,服务器 FQDN 为 ipa.hwdomain.io,因此域名必须为 hwdomain.io。
按 ENTER 确认并继续。
Warning: skipping DNS resolution of host ipa.hwdomain.io
The domain name has been determined based on the host name.
Please confirm the domain name [hwdomain.io]:
现在您需要为 Kerberos 身份验证设置 REALM 域名。在大多数情况下,它与 FreeIPA 域名相同,只是大写。
The kerberos protocol requires a Realm name to be defined.
This is typically the domain name converted to uppercase.
Please provide a realm name [HWDOMAIN.IO]:
输入目录服务器的新密码。密码必须至少为 8 个字符,因此请务必为目录管理器使用强密码。
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and has full access
to the Directory for system management tasks and will be added to the
instance of directory server created for IPA.
The password must be at least 8 characters long.
Directory Manager password:
Password (confirm):
现在为 IPA 管理员用户输入另一个密码。该用户将用于登录 FreeIPA 服务器或以管理员用户身份针对 Kerberos 进行身份验证。请务必为您的 IPA 管理员用户使用强密码。
The IPA server requires an administrative user, named 'admin'.
This user is a regular system account used for IPA server administration.
IPA admin password:
Password (confirm):
在下一步中,系统会要求您设置 DNS 转发器。按 ENTER 继续,FreeIPA 将自动检测当前 /etc/resolv.conf 文件作为 DNS 转发器。
Checking DNS domain hwdomain.io., please wait ...
Do you want to configure DNS forwarders? [yes]: yes
Following DNS servers are configured in /etc/resolv.conf: 192.168.121.1
Do you want to configure these servers as DNS forwarders? [yes]:
现在您将被要求为您的 FreeIPA 服务器 IP 地址创建一个反向区域。按 ENTER 继续,FreeIPA 将自动为您的服务器 IP 地址创建一个新的反向区域。
Do you want to search for missing reverse zones? [yes]:
Do you want to create reverse zone for IP 192.168.10.25 [yes]:
Please specify the reverse zone name [10.168.192.in-addr.arpa.]:
Using reverse zone(s) 10.168.192.in-addr.arpa.
Trust is configured but no NetBIOS domain name found, setting it now.
Enter the NetBIOS name for the IPA domain.
Only up to 15 uppercase ASCII letters, digits and dashes are allowed.
Example: EXAMPLE.
NetBIOS domain name [HWDOMAIN]:
对于 NTP 配置,将其保留为默认值并按 ENTER 键选择否。
Do you want to configure chrony with NTP server or pool address? [no]:
现在您将被要求确认 FreeIPA 服务器的安装和配置。再次查看FreeIPA服务器的详细配置,然后输入yes回车确认安装配置。
The IPA Master Server will be configured with:
Hostname: ipa.hwdomain.io
IP address(es): 192.168.10.25
Domain name: hwdomain.io
Realm name: HWDOMAIN.IO
The CA will be configured with:
Subject DN: CN=Certificate Authority,O=HWDOMAIN.IO
Subject base: O=HWDOMAIN.IO
Chaining: self-signed
BIND DNS server will be configured to serve IPA domain with:
Forwarders: 192.168.121.1
Forward policy: only
Reverse zone(s): 10.168.192.in-addr.arpa.
Continue to configure the system with these values? [no]: yes
现在 FreeIPA 安装和配置将开始。
The following operations may take some minutes to complete.
Please wait until the prompt is returned.
Disabled p11-kit-proxy
Synchronizing time
No SRV records of NTP servers found and no NTP server or pool address was provided.
Using default chrony configuration.
Attempting to sync time with chronyc.
Time synchronization was successful.
Configuring directory server (dirsrv). Estimated time: 30 seconds
[1/41]: creating directory server instance
[2/41]: tune ldbm plugin
[3/41]: adding default schema
[4/41]: enabling memberof plugin
安装和配置 FreeIPA 后,您将看到以下输出消息。
在下面的输出消息中,您还将了解为 FreeIPA 服务器设置防火墙的下一步。您需要为 FreeIPA 服务器打开一些端口,然后使用管理员用户对 Kerberos 服务器验证身份验证。
==============================================================================
Setup complete
Next steps:
1. You must make sure these network ports are open:
TCP Ports:
* 80, 443: HTTP/HTTPS
* 389, 636: LDAP/LDAPS
* 88, 464: kerberos
* 53: bind
UDP Ports:
* 88, 464: kerberos
* 53: bind
* 123: ntp
2. You can now obtain a Kerberos ticket using the command: 'kinit admin'
This ticket will allow you to use the IPA tools (e.g., ipa user-add)
and the web user interface.
Be sure to back up the CA certificates stored in /root/cacert.p12
These files are required to create replicas. The password for these
files is the Directory Manager password
The ipa-server-install command was successful
现在您已经完成了 FreeIPA 服务器的安装和配置。
设置防火墙
在此步骤中,您将向 Firewalld 规则添加一些服务。这包括 FreeIPA 服务器的基本服务,例如 LDAP、DNS 和 HTTPS。
运行下面的 firewall-cmd 命令,将 FreeIPA 服务器的一些服务添加到 Firewalld。
sudo firewall-cmd --add-service={http,https,dns,ntp,freeipa-ldap,freeipa-ldaps} --permanent
之后,使用以下命令重新加载 Firewalld 规则。
sudo firewall-cmd --reload
最后,使用以下命令验证 Firewalld 的规则列表。
sudo firewall-cmd --list-all
在下面的屏幕截图中,您将 FreeIPA 服务器的所有服务都添加到 Firewalld。

验证 Kerberos 管理员身份验证
设置 Firewalld 后,现在您将验证针对 FreeIPA 服务器上的 Kerberos 的身份验证。
运行以下命令以使用管理员用户对 Kerberos 服务器进行身份验证。
kinit admin
现在系统将提示您输入 IPA 服务器的密码。输入正确的密码。
成功通过身份验证后,运行以下命令以验证服务器上的 Kerberos 票证列表。
klist
在下面的屏幕截图中,用户 admin 的新 Kerberos 票证可用,并且针对 Kerberos 服务器的身份验证成功。

登录到 FreeIPA 仪表板
在此步骤中,您将通过登录 FreeIPA Web 管理仪表板来验证 FreeIPA 安装。
打开您的网络浏览器并访问您的服务器 IP 地址或 FQDN,如下所示。现在您将看到 FreeIPA 登录页面。
输入 FreeIPA 管理员用户和密码,然后单击“登录”按钮。

登录后,您将在下方看到 FreeIPA 管理仪表板。

结论
恭喜!您现在已经在 Rocky Linux 上成功安装和配置了 FreeIPA。此外,您已使用 IPA 管理员用户成功通过 Kerberos 服务器的身份验证并登录到 FreeIPA 服务器。