在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器

发表 admin at 2025年2月28日
类别
  • 未分类
标签

在本文中,我们详细讨论了 Rocky Linux 9/AlmaLinux 9 系统上 FreeIPA Server 的安装和配置。 FreeIPA 是流行且广泛使用的身份管理解决方案,可用于管理 Linux 域中的用户身份验证、策略的创建和执行、身份存储和授权策略。 FreeIPA 旨在消除在大中型 Linux 驱动的基础设施中工作的 Linux 管理员的开销。

FreeIPA 的一些高级功能是:

  • 支持大型 Linux 机器组
  • 与 Windows Active Directory 进行本机集成
  • Linux操作系统环境的高级功能
  • 完整的多主复制以实现更高的冗余和可扩展性
  • 提供可扩展的管理界面(Web UI、CLI、XMLRPC 和 JSONRPC API)和 Python SDK

使用 FreeIPA 的主要优点

  • 集中身份验证管理 – 对大型 Linux/Unix 企业环境中的用户、计算机和服务进行集中管理。
  • 细粒度访问控制:提供明确的方法来定义访问控制策略,以管理用户身份和管理任务委派。
  • 一次性密码(OTP):提供一种实现双因素身份验证(2FA)的流行方法。
  • 直接连接到 Active Directory:您可以从 Active Directory (AD) 检索信息并以标准方式加入域或领域。
  • Active Directory 跨领域信任:作为系统管理员,您可以与 Microsoft Active Directory 建立跨林 Kerberos 信任。这允许外部 Active Directory (AD) 用户方便地访问身份管理域中的资源。
  • 集成公钥基础设施 (PKI) 服务:该服务提供为主机和服务签署和发布证书的 PKI 服务、用于验证已发布证书的软件的证书吊销列表 (CRL) 和 OCSP 服务,以及用于请求、出示和查找证书。

在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA 服务器

确保在新安装的 Rocky Linux 9/AlmaLinux 9 系统上完成此安装,因为 IPA 服务端口可能与其他 Linux 服务发生冲突。

第 1 步:更新系统,设置主机名、时区

更新您的 Rocky Linux/AlmaLinux 8 服务器:

sudo yum -y update
sudo reboot

重新启动后,设置正确的系统主机名。

sudo hostnamectl set-hostname ipa.example.com

主机名必须是完全限定的域名,例如 ipa.example.com。设置后,还要配置系统时区以匹配您的区域:

sudo timedatectl set-timezone Africa/Nairobi

确认您的时区设置:

$ timedatectl
               Local time: Wed 2022-07-27 21:44:27 EAT
           Universal time: Wed 2022-07-27 18:44:27 UTC
                 RTC time: Wed 2022-07-27 18:44:27
                Time zone: Africa/Nairobi (EAT, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

第 2 步:检查 FreeIPA 服务器安装先决条件

主要 FreeIPA 服务器组件包括:

  • MIT Kerberos KDC – 提供单点登录身份验证解决方案
  • 389 目录服务器 – 主要数据存储并提供完整的多主 LDAPv3 目录基础设施。
  • ISC 绑定 DNS 服务器 – 绑定是 FreeIPA 中的默认域名解析服务。
  • Dogtag 证书系统 – 该组件提供用于证书管理功能的 CA 和 RA。
  • NTP 服务器 – 用于加入域的节点群之间的时间同步
  • Web UI/CLI 界面 – 用于集中管理访问控制、管理任务委派和其他网络管理任务。

在 Rocky Linux 9/AlmaLinux 9 上安装 FreeIPA Server 的最低硬件要求:

  • 4GB 内存
  • 2 个 vCPU
  • FQDN – 它必须可以从系统中配置的 DNS 服务器解析
  • 至少 10 GB 可用磁盘空间

使用下面共享的命令检查 Rocky Linux 9/AlmaLinux 9 实例上的 CPU、内存和磁盘空间。

# CPU Cores
$ grep -c ^processor /proc/cpuinfo
4

# Memory check
$ free -h

# Disk space
$ lsblk  -fp

在 /etc/hosts 文件中添加 FreeIPA 服务器 IP 地址及其 DNS 名称:

$ sudo vi /etc/hosts
 172.20.30.252 ipa.example.com

验证您的 IP 设置:

$ hostname --ip-address
172.20.30.252

使用 dig 命令验证您的 DNS 服务器中的反向 DNS 配置(PTR 记录)是否设置正确:

$ dig +short -x <ServerIPAddress>

步骤 3:安装和配置 FreeIPA 服务器

接下来我们在 Rocky Linux 9/AlmaLinux 9 服务器上安装 FreeIPA 软件包。不需要额外的 RPM 存储库,所有软件包和依赖项都在默认操作系统默认存储库中可用。

使用以下命令安装所有 FreeIPA 服务器和客户端软件包:

sudo dnf -y install freeipa-server freeipa-server-dns freeipa-client

运行 FreeIPA 服务器安装程序

FreeIPA 服务器配置是使用 ipa-server-install 命令行工具完成的。安装程序脚本将在 /var/log/ipaserver-install.log 处创建一个日志文件:

sudo ipa-server-install

该脚本会提示几个必需的设置,并在括号中提供建议的默认值。

  • 要接受默认值,请按Enter。
  • 要提供自定义值,请输入所需的值。
对于不带 DNS 的 IdM 非交互式安装:
sudo ipa-server-install --realm EXAMPLE.COM \
  --ds-password DM_password \
  --admin-password admin_password \
  --unattended

# OR
sudo ipa-server-install \
    --domain example.com \
    --realm EXAMPLE.COM \
    --ds-password DM_password \
    --admin-password admin_password

非交互式安装所需的最低选项是:

  • --realm 提供 Kerberos 领域名称
  • --ds-password 提供目录管理员 (DM)(目录服务器超级用户)的密码
  • --admin-password 提供 IdM 管理员 admin 的密码
  • --unattended 让安装过程选择主机名和域名的默认选项
具有集成 DNS 的 IdM 的非交互式安装:
sudo ipa-server-install --domain example.com --realm EXAMPLE.COM \
    --reverse-zone=30.20.172.in-addr.arpa. \
    --no-forwarders \
    --no-ntp \
    --setup-dns \
    --ds-password StrongDMPassw0rd \
    --admin-password StrongDMPassw0rd \
    --unattended

FreeIPA服务器的交互式安装

请参阅下文,了解安装过程中您将收到的完整提示和预期响应:

$ sudo ipa-server-install

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.8

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 SID generation
  * Configure the KDC to enable PKINIT

To accept the default shown in brackets, press the Enter key.

Do you want to configure integrated DNS (BIND)? [no]: yes

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.example.com]: ipa.example.com

The domain name has been determined based on the host name.

Please confirm the domain name [example.com]: example.com

The kerberos protocol requires a Realm name to be defined.
This is typically the domain name converted to uppercase.

Please provide a realm name [EXAMPLE.COM]: EXAMPLE.COM
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: <Directory-Manager-Password>
Password (confirm): <Confirm-Directory-Manager-Password>

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):

Do you want to configure chrony with NTP server or pool address? [no]: yes
Enter NTP source server addresses separated by comma, or press Enter to skip: 0.de.pool.ntp.org,1.de.pool.ntp.org
Enter a NTP source pool address, or press Enter to skip:

The IPA Master Server will be configured with:
Hostname:       ipa.example.com
IP address(es): 172.20.30.252
Domain name:    example.com
Realm name:     EXAMPLE.COM

The CA will be configured with:
Subject DN:   CN=Certificate Authority,O=EXAMPLE.COM
Subject base: O=EXAMPLE.COM
Chaining:     self-signed

NTP server:	0.de.pool.ntp.org
NTP server:	1.de.pool.ntp.org
Continue to configure the system with these values? [no]: yes

The following operations may take some minutes to complete.
Please wait until the prompt is returned.

Disabled p11-kit-proxy
Synchronizing time
Configuration of chrony was changed by installer.
Attempting to sync time with chronyc.
Process chronyc waitsync failed to sync time!
Unable to sync time with chrony server, assuming the time is in sync. Please check that 123 UDP port is opened, and any time server is on network.
Warning: IPA was unable to sync time with chrony!
         Time synchronization is required for IPA to work correctly
Configuring directory server (dirsrv). Estimated time: 30 seconds
  [1/41]: creating directory server instance
  [2/41]: tune ldbm plugin
.....

如果您在 Rocky Linux 9/AlmaLinux 9 上的 FreeIPA 服务器安装成功,预计输出类似于以下内容:

......
Sudoers I/O plugin version 1.8.29
Client hostname: ipa.example.com
Realm: EXAMPLE.COM
DNS Domain: example.com
IPA Server: ipa.example.com
BaseDN: dc=example,dc=com

Configured sudoers in /etc/authselect/user-nsswitch.conf
Configured /etc/sssd/sssd.conf
Systemwide CA database updated.
Adding SSH public key from /etc/ssh/ssh_host_ecdsa_key.pub
Adding SSH public key from /etc/ssh/ssh_host_ed25519_key.pub
Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub
Could not update DNS SSHFP records.
SSSD enabled
Configured /etc/openldap/ldap.conf
Configured /etc/ssh/ssh_config
Configured /etc/ssh/sshd_config
Configuring example.com as NIS domain.
Client configuration complete.
The ipa-client-install command was successful

Please add records in this file to your DNS system: /tmp/ipa.system.records.hh7e7u2h.db
==============================================================================
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
		UDP Ports:
		  * 88, 464: kerberos
		  * 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服务端口

FreeIPA服务端口列表如下表所示:

让我们使用firewall-cmd打开防火墙上的端口:

sudo firewall-cmd --add-service={dns,ntp,freeipa-ldap,freeipa-ldaps} --permanent

然后重新加载firewalld配置以使更改立即生效:

sudo firewall-cmd --reload

列出防火墙上允许的服务:

$ sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens18
  sources:
  services: cockpit dhcpv6-client dns freeipa-ldap freeipa-ldaps ntp ssh
  ....

第 4 步:访问 FreeIPA 管理仪表板

安装后,可以使用 https 上的服务器主机名访问基于 Web 的 FreeIPA Server 管理控制台:

https://ipa.example.com

通过点击“高级”>“继续访问 ipa.example.com(不安全)”来忽略 SSL 警告

使用安装期间设置的管理员用户名和密码登录。

成功登录后,您将看到一个外观如下的界面:

第 5 步:使用 Let's Encrypt SSL 保护 FreeIPA

安装后,我们建议在 FreeIPA 服务器上使用安全 SSL。如果在公共实例上运行,请遵循下一个链接中的指南:

  • 使用 Let’s Encrypt SSL 证书保护 FreeIPA 服务器的安全

第 6 步:使用 CLI 界面管理 FreeIPA

ipa 命令可用于执行所有 FreeIPA 服务器操作。但首先,获取管理员用户 Kerberos 票证:

$ kinit admin
Password for [email :

可以使用klist检查分配票证的时间有效性:

$ klist
Ticket cache: KCM:0
Default principal: [email 

Valid starting               Expires                               Service principal
07/27/2022 17:42:38  07/28/2022 21:49:26          krbtgt/[email 

将用户的默认 shell 设置为 /bin/bash。

$ ipa config-mod --defaultshell=/bin/bash 
   Maximum username length: 32
   Home directory base: /home
   Default shell: /bin/bash
   Default users group: ipausers
   Default e-mail domain: example.com
   Search time limit: 2
   Search size limit: 100
   User search fields: uid,givenname,sn,telephonenumber,ou,title
   Group search fields: cn,description
   Enable migration mode: FALSE
   Certificate Subject base: O=EXAMPLE.COM
   Password Expiration Notification (days): 4
   Password plugin features: AllowNThash, KDC:Disable Last Success
   SELinux user map order: guest_u:s0$xguest_u:s0$user_u:s0$staff_u:s0-s0:c0.c1023$unconfined_u:s0-s0:c0.c1023
   Default SELinux user: unconfined_u:s0-s0:c0.c1023
   Default PAC types: MS-PAC, nfs:NONE
   IPA masters: ipa.example.com
   IPA CA servers: ipa.example.com
   IPA CA renewal master: ipa.example.com
   IPA master capable of PKINIT: ipa.example.com

通过添加用户帐户并列出存在的帐户进行测试:

$ ipa user-add test  --first=Test --last=User [email  --password

Password: 
Enter Password again to verify: 
-------------------
 Added user "test"
-------------------
   User login: test
   First name: Test
   Last name: User
   Full name: Test User
   Display name: Test User
   Initials: TU
   Home directory: /home/test
   GECOS: Test User
   Login shell: /bin/bash
   Principal name: [email 
   Principal alias: [email 
   User password expiration: 20210802153038Z
   Email address: [email 
   UID: 1201400001
   GID: 1201400001
   Password: True
   Member of groups: ipausers
   Kerberos keys available: True

要列出添加的用户帐户,请运行:

$ ipa user-find
---------------
2 users matched
---------------
  User login: admin
  Last name: Administrator
  Home directory: /home/admin
  Login shell: /bin/bash
  Principal alias: [email 
  UID: 1201400000
  GID: 1201400000
  Account disabled: False

  User login: test
  First name: Test
  Last name: User
  Home directory: /home/test
  Login shell: /bin/bash
  Principal name: [email 
  Principal alias: [email 
  Email address: [email 
  UID: 1201400001
  GID: 1201400001
  Account disabled: False
----------------------------
Number of entries returned 2
----------------------------

尝试以test用户身份登录。首次登录时,系统会要求您更改密码:

$ ssh test@localhost
Password: 
Password expired. Change your password now.
Current Password: 
New password: <Set new password>
Retype new password: 
Activate the web console with: systemctl enable --now cockpit.socket
[test1@ipa ~]$ id
uid=1201400003(test1) gid=1201400003(test1) groups=1201400003(test1) cont

如果您想修改用户密码有效期,请参考以下指南:

  • 更改 FreeIPA 用户密码最长有效期 > 90 天

您可以使用该界面来了解各种 FreeIPA 管理功能的放置。在接下来的指南中,我们将介绍使用示例 - FreeIPA 服务器如何帮助进行基础设施范围内的用户、组、主机和策略管理。保持联系以获取更新。

更多 FreeIPA 指南:

  • 使用 FreeIPA LDAP 配置 oVirt/RHEV 用户身份验证
  • 在 Docker/Podman 容器中运行 FreeIPA 服务器
  • 使用 CLI 管理 FreeIPA 中的用户和组

推荐阅读的 Linux 书籍:

  • 适合初学者和专家的最佳 Linux 书籍
  • 最佳 Linux 内核编程书籍
  • 最佳 Linux Bash 脚本书籍
  • 顶级 RHCSA/RHCE 认证学习书籍
  • 最受好评的 CompTIA A+ 认证书籍
  • 最佳 LPIC-1 和 LPIC-2 认证学习书籍
©2015-2025 Norria support@alaica.com