Linux 加入 FreeIPA 域
Linux 其实可以不用加域,也可以通过 IPA 进行登录账号验证,只需要安装 sssd-ipa
。但如果需要像 Windows 一样加域,则需要安装 ipa-client
。ipa-client
的作用类似于 Windows 系统的“加域”操作(Join Domain)。它通过 ipa-client-install
工具,将一台 Linux 主机注册到 FreeIPA 服务器,使其成为 IPA 域的成员机。这个过程中会自动完成主机对象注册、Kerberos 机密分发,以及本地认证环境(如 sssd、kerberos、nsswitch 等)的配置,从而让该主机能够使用 IPA 统一认证和集中管理。
在客户端认证的实现层面,sssd-ipa
是 SSSD(System Security Services Daemon)服务中专门用于对接 FreeIPA 的 provider(后端模块),负责与 FreeIPA 服务器进行通信、缓存账号和组信息、处理认证请求、管理 Kerberos 票据等核心功能。sssd-ipa
是实现“用 IPA 账号登录和认证”这一能力的关键技术组件。
LDAP 管理客户端配置
# 安装软件包
[root@client-001 ~]# dnf install sssd sssd-ipa sssd-ldap sssd-tools openldap-clients oddjob-mkhomedir
# 修改 ldap 认证配置
[root@client-001 ~]# cat /etc/openldap/ldap.conf | grep -v "#" | grep -v "^$"
SASL_NOCANON on
# LDAPS 服务器地址
URI ldaps://ldap-001.rockylinux.lan
# 基础域
BASE dc=rockylinux,dc=lan
# 证书,需要从服务器端同步过来,因为是自签名证书,后续将讲解采用 Let's Encrypt 免费公有证书的解决方案
TLS_CACERT /etc/openldap/certs/ca.cert
SASL_MECH GSSAPI
# 同步服务器端证书
[root@client-001 ~]# scp ldap-001.rockylinux.lan:/etc/ipa/ca.crt /etc/openldap/certs/ca.cert
# 测试查询账号是否正常
[root@client-001 ~]# ldapsearch -x uid=admin
# admin, users, compat, rockylinux.lan
dn: uid=admin,cn=users,cn=compat,dc=rockylinux,dc=lan
objectClass: posixAccount
objectClass: ipaOverrideTarget
objectClass: top
gecos: Administrator
cn: Administrator
uidNumber: 608200000
gidNumber: 608200000
loginShell: /bin/bash
homeDirectory: /home/admin
......(略)
其中涉及多个组件,以下是各组件的简要说明:
-
sssd
- 全称:System Security Services Daemon
- 作用:提供集中身份认证服务,支持多种后端(如 LDAP、IPA、AD 等)。
- 功能:本地缓存账号&组信息、本地认证、离线认证等。
- 简单说:SSSD 是“认证服务的框架和核心守护进程”。
-
sssd-ipa
- SSSD 的一个模块(provider),专门用于对接 FreeIPA 服务器。
- 作用:让 SSSD 能直接与 FreeIPA 进行认证、账户、组信息的通信与缓存。
- 简单说:用于实现 Linux 客户端与 FreeIPA 域的认证和信息同步。如果只是 IPA 服务器对接认证,只需要此软件包即可,不需要 SSSD 完整包。
-
sssd-ldap
- 也是 SSSD 的一个模块(provider),用于连接通用的 LDAP 目录(比如 OpenLDAP)。
- 作用:让 SSSD 能通过标准 LDAP 协议与目录服务通信,认证用户、拉取信息。
- 简单说:让 SSSD 通过 LDAP 协议做认证(不限于 IPA,可以是 OpenLDAP、389DS 等)。
-
sssd-tools
- 工具包,包含诸如
sssctl
、sss_cache
、sss_debuglevel
等实用命令。 - 作用:帮助管理员调试、排错、查看 SSSD 状态和缓存。
- 简单说:SSSD 运维管理和调试用的工具集合。
- 工具包,包含诸如
-
openldap-clients
- 一组常用 LDAP 命令行客户端工具(如
ldapsearch
、ldapadd
、ldapmodify
、ldapdelete
等)。 - 作用:方便管理员直接操作和管理 LDAP 目录服务器数据。
- 简单说:LDAP 通用命令行客户端工具包。
- 一组常用 LDAP 命令行客户端工具(如
-
oddjob-mkhomedir
- 一个 PAM 集成的小工具/守护进程。
- 作用:用户首次登录本机时,当用户家目录不存在时,自动创建个人家目录。
- 简单说:自动创建用户家目录的后台服务,常与 sssd/pam 使用。
通过配置 ldap.conf,已经实现了通过 ldapsearch
、ldapadd
、ldapmodify
、ldapdelete
等命令行工具管理 LDAP 服务器的需求。但客户端还不能够通过 LDAP 账号进行认证登录,还需要配置 SSSD 服务。
SSSD 认证客户端配置
默认不存在 sssd.conf
文件,可以参考 RedHat 官方文档进行配置,详细参阅:Chapter 4. Configuring SSSD to use LDAP and require TLS authentication | Configuring authentication and authorization in RHEL。
# 详细配置如下
[root@client-001 ~]# cat /etc/sssd/sssd.conf
[sssd]
services = nss, pam
domains = rockylinux.lan # 设置 LDAP 基础域
[nss]
[domain/rockylinux.lan] # 设置 LDAP 基础域
ldap_id_use_start_tls = True # 启用 LDAPS 安全通讯认证
id_provider = ldap # 账号/组信息提供者,可以是 ad、ipa、ldap,查询用户和组的来源为LDAP目录
autofs_provider = ldap # 自动挂载信息提供者,自动挂载(如NFS)规则从 LDAP 查询
auth_provider = ldap # 认证(登录验证)提供者,登录认证交给 LDAP 目录,到目录服务器验证用户名密码
chpass_provider = ldap # 密码修改操作提供者,修改密码操作通过LDAP目录执行
ldap_uri = ldaps://ldap-001.rockylinux.lan # 指定要连接的 LDAP 服务器的 URI(统一资源标识符),包括协议和主机地址
ldap_search_base = dc=rockylinux,dc=lan # 指定 LDAP 查询(用户、组、自动挂载等)时的起始基础搜索 DN
cache_credentials = True # 允许 SSSD 在本地缓存用户的认证凭据(如哈希后的密码等信息)
ldap_tls_cacertdir = /etc/openldap/certs # 指定 CA 根证书目录,用于验证 LDAP SSL 证书的合法性
ldap_tls_reqcert = demand # 指定客户端对服务器证书的验证级别,设为 demand,表示 “必须验证服务器证书”,并且如果验证失败则拒绝连接(最安全)。allow 如果不能验证则继续,never 永不验证,安全性较低。
# 检测配置,确保没有错误
[root@client-001 ~]# sssctl config-check
Issues identified by validators: 0
Messages generated during configuration merging: 0
Used configuration snippet files: 0
# 在切换身份验证提供程序 sssd 之前,先备份以下文件,以备不时之需
[root@client-001 ~]# cp -rf /etc/pam.d/system-auth /etc/pam.d/system-auth.bak
[root@client-001 ~]# cp -rf /etc/pam.d/password-auth /etc/pam.d/password-auth.bak
[root@client-001 ~]# cp -rf /etc/pam.d/fingerprint-auth /etc/pam.d/fingerprint-auth.bak
[root@client-001 ~]# cp -rf /etc/pam.d/smartcard-auth /etc/pam.d/smartcard-auth.bak
[root@client-001 ~]# cp -rf /etc/pam.d/postlogin /etc/pam.d/postlogin.bak
[root@client-001 ~]# cp -rf /etc/nsswitch.conf /etc/nsswitch.conf.bak
# 将身份验证提供程序切换为 sssd,并设置在用户首次登录本机,自动创建对应 Home 目录
[root@client-001 ~]# authselect select sssd with-mkhomedir --force
Backup stored at /var/lib/authselect/backups/2025-06-27-03-02-25.Ui7huJ # 如果您未手动执行上面的备份操作,默认 authselect 切换时,也会执行备份操作,备份目录即 /var/lib/authselect/backups/
Profile "sssd" was selected.
The following nsswitch maps are overwritten by the profile:
- passwd
- group
- netgroup
- automount
- services
Make sure that SSSD service is configured and enabled. See SSSD documentation for more information.
- with-mkhomedir is selected, make sure pam_oddjob_mkhomedir module
is present and oddjobd service is enabled and active
- systemctl enable --now oddjobd.service
# 启用 oddjobd 服务
[root@client-001 ~]# systemctl enable --now oddjobd
[root@client-001 ~]# systemctl status oddjobd
● oddjobd.service - privileged operations for unprivileged applications
Loaded: loaded (/usr/lib/systemd/system/oddjobd.service; enabled; preset: disabled)
Active: active (running) since Thu 2025-06-02 19:19:03 CST; 15h ago
Main PID: 9903 (oddjobd)
Tasks: 1 (limit: 48887)
Memory: 592.0K
CPU: 7ms
CGroup: /system.slice/oddjobd.service
└─9903 /usr/sbin/oddjobd -n -p /run/oddjobd.pid -t 300
# 启用 SSSD 服务
[root@client-001 ~]# systemctl enable --now sssd
[root@client-001 ~]# systemctl status sssd
● sssd.service - System Security Services Daemon
Loaded: loaded (/usr/lib/systemd/system/sssd.service; enabled; preset: enabled)
Active: active (running) since Thu 2025-06-02 19:20:42 CST; 3s ago
Main PID: 9558 (sssd)
Tasks: 4 (limit: 48887)
Memory: 43.9M
CPU: 312ms
CGroup: /system.slice/sssd.service
├─9558 /usr/sbin/sssd -i --logger=files
├─9559 /usr/libexec/sssd/sssd_be --domain rockylinux.lan --uid 0 --gid 0 --logger=files
├─9561 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
└─9562 /usr/libexec/sssd/sssd_pam --uid 0 --gid 0 --logger=files
# 验证 ID 查询是否正常
[root@client-001 ~]# id muzilee
uid=608200006(muzilee) gid=608200006(muzilee) groups=608200006(muzilee),608200000(admins)
[root@client-001 ~]# id admin
uid=608200000(admin) gid=608200000(admins) groups=608200000(admins)
# 切换登录用户,同时会创建用户 Home 目录
[root@client-001 ~]# su - muzilee
Creating home directory for muzilee.
Last login: Thu Jun 26 19:19:44 CST 2025 on pts/0
[muzilee@localhost ~]$ ls -l /ldaphome/
total 0
drwx------ 2 muzilee muzilee 62 Jun 2 11:03 muzilee
[muzilee@localhost ~]$ exit
logout
# 如果未安装 with-mkhomedir,将不会自动创建用户 Home 目录,并且切换时,提示如下
[root@client-001 ~]# su - muzilee
su: warning: cannot change directory to /ldaphome/muzilee: No such file or directory
这里详细说一下 4 个 provider
的作用:
-
id_provider = ldap
- 作用:指定本地用户和组信息(如 id、gid、组成员等)由 LDAP 目录服务提供。
- 简单理解:通过 LDAP 服务器(比如 OpenLDAP、FreeIPA、389DS)获取用户账号和组的基础数据。
- 常用场景:当系统账号信息都维护在 LDAP 时,这样配置可以让系统命令(如
id
、getent
、groups
)查到 LDAP 目录提供的信息。
-
autofs_provider = ldap
- 作用:指定自动挂载(autofs)相关信息(比如 NFS 目录自动挂载规则)由 LDAP 目录服务提供。
- 简单理解:如果您使用 autofs 并把挂载规则(map)存储在 LDAP,配置此参数让 SSSD 通过 LDAP 获取这些信息,实现自动挂载。
- 常用场景:集中式自动挂载管理,常见于身份、主目录或共享目录统一调度的企业环境。
-
auth_provider = ldap
- 作用:指定用户认证(即登录验证)由 LDAP 目录服务完成。
- 简单理解:用户登录时,SSSD 通过 LDAP 协议请求服务器鉴别用户名与密码是否正确。
- 注意:LDAP 认证通常需要启用安全传输(如 ldaps、starttls),否则密码可能被明文传输。现代很多方案更推荐用 Kerberos。
- 常用场景:LDAP 作为认证源时(不接入 Kerberos)。
-
chpass_provider = ldap
- 作用:指定修改密码操作通过 LDAP 目录服务处理。
- 简单理解:当用户尝试修改(或重置)自己在目录服务中的密码时,实际改动都由 SSSD 通过 LDAP 服务器执行。
- 常用场景:企业或校园网中用户自助修改密码的统一通道。
IPA-Client 客户端配置
# ipa-client-install 帮助信息
[root@client-001 ~]# ipa-client-install -h
Usage: ipa-client-install [options] # 用法:ipa-client-install [选项]
Options: # 选项列表:
--version show program s version number and exit
# 显示程序版本号并退出
-h, --help show this help message and exit
# 显示此帮助信息并退出
-U, --unattended unattended (un)installation never prompts the user
# 全自动(卸)安装,不提示用户交互
--uninstall uninstall an existing installation. The uninstall can
be run with --unattended option
# 卸载已存在的安装。可以与 --unattended 一起使用
Basic options: # 基本选项:
-p PRINCIPAL, --principal=PRINCIPAL
principal to use to join the IPA realm
# 用于加入 IPA 域的主体(principal)
--ca-cert-file=FILE
load the CA certificate from this file
# 从指定文件加载 CA 证书
--ip-address=IP_ADDRESS
Specify IP address that should be added to DNS. This
option can be used multiple times
# 指定要添加到 DNS 的 IP 地址(可多次使用此选项)。使用 FreeIPA 自带 DNS 时,此选项可用。
--all-ip-addresses All routable IP addresses configured on any interface
will be added to DNS
# 会将所有接口上可路由 IP 地址添加到 DNS。使用 FreeIPA 自带 DNS 时,此选项可用。
--domain=DOMAIN_NAME
primary DNS domain of the IPA deployment (not
necessarily related to the current hostname)
# IPA 部署的主 DNS 域名(不一定与当前主机名相关)
--server=SERVER FQDN of IPA server
# IPA 服务器的 FQDN
--realm=REALM_NAME Kerberos realm name of the IPA deployment (typically
an upper-cased name of the primary DNS domain)
# IPA 部署的 Kerberos 域名(通常是主 DNS 域名的大写)
--hostname=HOST_NAME
The hostname of this machine (FQDN). If specified, the
hostname will be set and the system configuration will
be updated to persist over reboot. By default the
result of getfqdn() call from Python s socket module
is used.
# 设置本机的主机名(FQDN)。指定后主机名会保存为永久配置,否则使用默认 Python socket.getfqdn() 的结果
Client options: # 客户端选项:
-w PASSWORD, --password=PASSWORD
password to join the IPA realm (assumes bulk password
unless principal is also set)
# 加入 IPA 域所需的密码(默认批量密码,除非也设置了 principal)
-W Prompt for a password to join the IPA realm
# 提示输入加入 IPA 域所需的密码
-f, --force force setting of LDAP/Kerberos conf
# 强制设置 LDAP/Kerberos 配置
--configure-firefox
configure Firefox to use IPA domain credentials
# 配置 Firefox 以使用 IPA 域凭证
--firefox-dir=FIREFOX_DIR
specify directory where Firefox is installed (for
example: '/usr/lib/firefox')
# 指定 Firefox 的安装目录(例如:'/usr/lib/firefox')
-k KEYTAB, --keytab=KEYTAB
path to backed up keytab from previous enrollment
# 使用之前注册时备份的 keytab 文件路径
--mkhomedir create home directories for users on their first login
# 用户首次登录时自动创建主目录
--force-join Force client enrollment even if already enrolled
# 即使已经加入,也强制客户机注册
--ntp-server=NTP_SERVER
ntp server to use. This option can be used multiple
times
# 指定 NTP 服务器(可多次使用此选项)
--ntp-pool=NTP_POOL
ntp server pool to use
# 指定 NTP 服务器池
-N, --no-ntp do not configure ntp
# 不配置 NTP
--nisdomain=NISDOMAIN
NIS domain name
# 指定 NIS 域名
--no-nisdomain do not configure NIS domain name
# 不配置 NIS 域名
--ssh-trust-dns configure OpenSSH client to trust DNS SSHFP records
# 配置 OpenSSH 客户端信任 DNS 中的 SSHFP 记录
--no-ssh do not configure OpenSSH client
# 不配置 OpenSSH 客户端
--no-sshd do not configure OpenSSH server
# 不配置 OpenSSH 服务端
--no-sudo do not configure SSSD as data source for sudo
# 不将 SSSD 配置为 sudo 的数据源
--subid configure SSSD as data source for subid
# 将 SSSD 配置为 subid 的数据源
--no-dns-sshfp do not automatically create DNS SSHFP records
# 不自动创建 DNS SSHFP 记录
--kinit-attempts=KINIT_ATTEMPTS
number of attempts to obtain host TGT (defaults to 5).
# 获取主机 TGT(票证授权票)的尝试次数(默认为 5 次)
--dns-over-tls Configure DNS over TLS
# 配置 DNS over TLS
SSSD options: # SSSD 选项:
--fixed-primary Configure sssd to use fixed server as primary IPA
server
# 配置 SSSD 使用指定服务器为主 IPA 服务器
--permit disable access rules by default, permit all access.
# 默认关闭访问控制规则,允许所有访问
--enable-dns-updates
Configures the machine to attempt dns updates when the
ip address changes.
# 配置主机在 IP 变更时自动尝试 DNS 更新
--no-krb5-offline-passwords
Configure SSSD not to store user password when the
server is offline
# 配置 SSSD 在服务器离线时不保存用户密码
--preserve-sssd Preserve old SSSD configuration if possible
# 如果可能,保留旧的 SSSD 配置
PKINIT options: # PKINIT(公钥初始化)选项:
--pkinit-identity=IDENTITY
PKINIT identity information (for example
FILE:/path/to/cert.pem,/path/to/key.pem)
# PKINIT 的身份信息(例如FILE:/path/to/cert.pem,/path/to/key.pem)
--pkinit-anchor=FILEDIR
PKINIT trust anchors, prefixed with FILE: for CA PEM
bundle file or DIR: for an OpenSSL hash dir. The
option can be used used multiple times.
# PKINIT 信任锚,FILE: 为 CA PEM 证书包,DIR: 为 OpenSSL 哈希目录(可多次使用)
Automount options: # 自动挂载选项:
--automount-location=AUTOMOUNT_LOCATION
Automount location
# 设置自动挂载位置
Logging and output options: # 日志和输出选项:
-v, --verbose print debugging information
# 打印调试信息
-d, --debug alias for --verbose (deprecated)
# --verbose 的别名(已弃用)
-q, --quiet output only errors
# 只输出错误信息
--log-file=FILE log to the given file
# 日志写入指定文件
加域
在使用 ipa-client-install
进行加域操作前,需要先设置主机名,确保主机名在域内唯一,并在 CoreDNS 上为该主机名添加对应的 A 记录,以保证域名能够正确解析。
# 客户端节点配置
# 设置主机名
[root@client-001 ~]# hostnamectl set-hostname client-001.rockylinux.lan
[root@client-001 ~]# hostname
client-001.rockylinux.lan
# 加域,详细参数设置参考前面的帮助信息
[root@client-001 ~]# ipa-client-install --hostname=`hostname -f` --mkhomedir --server=ldap-001.rockylinux.lan --domain rockylinux.lan --realm ROCKYLINUX.LAN
This program will set up IPA client.
Version 4.12.2
Autodiscovery of servers for failover cannot work with this configuration. # 此配置不支持自动发现服务器进行故障转移。如果您继续安装,服务将配置为始终访问已发现的服务器执行所有操作,并且在发生故障时不会故障转移到其他服务器。出现此提示的原因在于我们的 FreeIPA 服务器是单节点,下一章节我们将讲解 FreeIPA 集群部署
If you proceed with the installation, services will be configured to always access the discovered server for all operations and will not fail over to other servers in case of failure.
Proceed with fixed values and no DNS discovery? [no]: yes # 是否继续使用固定值且不使用 DNS 发现?
Do you want to configure chrony with NTP server or pool address? [no]: # 是否要为 chrony 配置 NTP 服务器或池地址?
Client hostname: client-001.rockylinux.lan
Realm: ROCKYLINUX.LAN
DNS Domain: rockylinux.lan
IPA Server: ldap-001.rockylinux.lan
BaseDN: dc=rockylinux,dc=lan
Continue to configure the system with these values? [no]: yes # 确认上面的配置没有问题后,输入 yes,开始加域
Synchronizing time # 时间同步
No SRV records of NTP servers found and no NTP server or pool address was provided. # 没有找到时间服务器的 SRV 解析(忽略)
Using default chrony configuration. # 使用默认的 chrony 配置
Attempting to sync time with chronyc. # 尝试使用 chronyc 同步时间
Time synchronization was successful. # 时间同步成功
User authorized to enroll computers: admin # 授权计算机注册用户 admin
Password for [email protected]: # 密码
Successfully retrieved CA cert # 已成功检索 CA 证书,到期时间 20 年
Subject: CN=Certificate Authority,O=ROCKYLINUX.LAN
Issuer: CN=Certificate Authority,O=ROCKYLINUX.LAN
Valid From: 2025-06-02 02:54:41+00:00
Valid Until: 2045-06-02 02:54:41+00:00
Enrolled in IPA realm ROCKYLINUX.LAN # 已注册 IPA 域 ROCKYLINUX.LAN
Created /etc/ipa/default.conf # 创建配置文件 /etc/ipa/default.conf
Domain rockylinux.lan is already configured in existing SSSD config, creating a new one. # 现有 SSSD 配置中已配置域 rockylinux.lan,请创建一个新域。
The old /etc/sssd/sssd.conf is backed up and will be restored during uninstall. # 旧的 /etc/sssd/sssd.conf 已备份,将在卸载过程中恢复。出现此提示,主要是因为前期木子已经配置了 SSSD 认证
Configured /etc/sssd/sssd.conf # 配置 /etc/sssd/sssd.conf
Systemwide CA database updated. # 系统范围的 CA 数据库已更新
Hostname (client-001.rockylinux.lan) does not have A/AAAA record. # 主机名 (client-001.rockylinux.lan) 没有 A/AAAA 记录。正常如果在 CoreDNS 上配置 A 记录解析,不会出现此提示。
Failed to update DNS records. # DNS 记录更新失败。
Missing A/AAAA record(s) for host client-001.rockylinux.lan: 192.168.3.1. # 主机 client-001.rockylinux.lan 缺少 A/AAAA 记录:192.168.3.1。
Missing reverse record(s) for address(es): 192.168.3.1. # 地址缺少反向记录:192.168.3.1。
Adding SSH public key from /etc/ssh/ssh_host_ed25519_key.pub # 正在从 /etc/ssh/ssh_host_ed25519_key.pub 添加 SSH 公钥
Adding SSH public key from /etc/ssh/ssh_host_ecdsa_key.pub # 正在从 /etc/ssh/ssh_host_ecdsa_key.pub 添加 SSH 公钥
Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub # 正在从 /etc/ssh/ssh_host_rsa_key.pub 添加 SSH 公钥
Could not update DNS SSHFP records. # 无法更新 DNS SSHFP 记录。
SSSD enabled # 启用 SSSD
Configured /etc/openldap/ldap.conf # 已配置 /etc/openldap/ldap.conf
Configured /etc/ssh/ssh_config # 已配置 /etc/ssh/ssh_config
Configured /etc/ssh/sshd_config.d/04-ipa.conf # 已配置 /etc/ssh/sshd_config.d/04-ipa.conf
Configuring rockylinux.lan as NIS domain. # 正将 rockylinux.lan 配置为 NIS 域。
Configured /etc/krb5.conf for IPA realm ROCKYLINUX.LAN # 已为 IPA 域 ROCKYLINUX.LAN 配置 /etc/krb5.conf
Client configuration complete. # 客户端配置完成
The ipa-client-install command was successful # ipa-client-install 命令已成功执行
# 此时获取用户信息成功
[root@client-001 ~]# id admin
uid=608200000(admin) gid=608200000(admins) groups=608200000(admins)
[root@client-001 ~]# id muzilee
uid=608200006(muzilee) gid=608200006(muzilee) groups=608200006(muzilee),608200000(admins)
# 切换用户登录成功
[root@client-001 ~]# su - muzilee
Last login: Fri Jun 2 11:03:54 CST 2025 on pts/0
[muzilee@client-001 ~]$ exit
logout
# 服务器端验证
# 服务器端能够正常查询到相应主机,表明计算机已成功加入域。
[root@ldap-001 ~]# ipa host-find
---------------
2 hosts matched
---------------
Host name: client-001.rockylinux.lan
Platform: x86_64
Operating system: 5.14.0-570.22.1.el9_6.x86_64
Principal name: host/[email protected]
Principal alias: host/[email protected]
SSH public key fingerprint: SHA256:gL0J6AOjDjgDOfpA+Y3l+cOb2C8S/zsO/U3YmxZ1NRA (ssh-ed25519), SHA256:R6kUNadGJdOB/eG7tEd+DpVj50uAOYLcvuuvmZcMBaE (ecdsa-sha2-nistp256), SHA256:KBmGKburcMYFau/4dKKOxAr6OBxMn8pbVMhYQxamrig (ssh-rsa)
Host name: ldap-001.rockylinux.lan
Principal name: host/[email protected]
Principal alias: host/[email protected]
SSH public key fingerprint: SHA256:mDUZ6LVZY3JBE//lk4u96z0ucDYdffaIp+yLW8mQvRs (ecdsa-sha2-nistp256), SHA256:RyqccO9MC0qABzHmmZJk2wFXKdFLH1ykUm1wiTV/PpQ (ssh-ed25519), SHA256:xi4s4u6qSRW3uzu9XNRKFTIT4Ff2Q2H4I6I/iP/hvvc (ssh-rsa)
----------------------------
Number of entries returned 2
----------------------------
[root@ldap-001 ~]# ipa host-find --hostname=client-001.rockylinux.lan
--------------
1 host matched
--------------
Host name: client-001.rockylinux.lan
Platform: x86_64
Operating system: 5.14.0-570.22.1.el9_6.x86_64
Principal name: host/[email protected]
Principal alias: host/[email protected]
SSH public key fingerprint: SHA256:gL0J6AOjDjgDOfpA+Y3l+cOb2C8S/zsO/U3YmxZ1NRA (ssh-ed25519), SHA256:R6kUNadGJdOB/eG7tEd+DpVj50uAOYLcvuuvmZcMBaE (ecdsa-sha2-nistp256), SHA256:KBmGKburcMYFau/4dKKOxAr6OBxMn8pbVMhYQxamrig (ssh-rsa)
----------------------------
Number of entries returned 1
----------------------------
退域
# 客户端进行卸载操作
[root@client-001 ~]# ipa-client-install --uninstall
Unenrolling client from IPA server # 正在从 IPA 服务器取消客户端注册
Removing Kerberos service principals from /etc/krb5.keytab # 正在从 /etc/krb5.keytab 中删除 Kerberos 服务主体
Disabling client Kerberos and LDAP configurations # 正在禁用客户端 Kerberos 和 LDAP 配置
Restoring client configuration files # 正在恢复客户端配置文件
Unconfiguring the NIS domain. # 正在取消配置 NIS 域
nscd daemon is not installed, skip configuration # nscd 守护进程未安装,跳过配置
nslcd daemon is not installed, skip configuration # nslcd 守护进程未安装,跳过配置
Systemwide CA database updated. # 系统范围的 CA 数据库已更新
Client uninstall complete. # 客户端卸载完成
The original nsswitch.conf configuration has been restored. # 原始 nsswitch.conf 配置已恢复
You may need to restart services or reboot the machine. # 您需要重启服务或重新启动计算机
Do you want to reboot the machine? [no]: yes # 是否要重新启动计算机?[否]: 输入 yes,重启计算机
The ipa-client-install command was successful # ipa-client-install 命令已成功执行
# 计算机重启后,测试获取用户与切换用户失败,说明退域成功
[root@client-001 ~]# id muzilee
id: ‘muzilee’: no such user
[root@client-001 ~]# su - muzilee
su: user muzilee does not exist or the user entry does not contain all the required fields
# 退域并不会主动删除服务器端主机信息,需要在 IPA 服务器端手动删除(FreeIPA 服务器端操作)
[root@ldap-001 ~]# ipa host-find --hostname=client-001.rockylinux.lan
--------------
1 host matched
--------------
Host name: client-001.rockylinux.lan
Platform: x86_64
Operating system: 5.14.0-570.22.1.el9_6.x86_64
Principal name: host/[email protected]
Principal alias: host/[email protected]
SSH public key fingerprint: SHA256:gL0J6AOjDjgDOfpA+Y3l+cOb2C8S/zsO/U3YmxZ1NRA (ssh-ed25519), SHA256:R6kUNadGJdOB/eG7tEd+DpVj50uAOYLcvuuvmZcMBaE (ecdsa-sha2-nistp256), SHA256:KBmGKburcMYFau/4dKKOxAr6OBxMn8pbVMhYQxamrig (ssh-rsa)
----------------------------
Number of entries returned 1
----------------------------
# 删除客户端 client-001.rockylinux.lan
[root@ldap-001 ~]# ipa host-del client-001.rockylinux.lan
----------------------------------------
Deleted host "client-001.rockylinux.lan"
----------------------------------------
# 查询返回客户端为 0,说明删除成功
[root@ldap-001 ~]# ipa host-find --hostname=client-001.rockylinux.lan
---------------
0 hosts matched
---------------
----------------------------
Number of entries returned 0
----------------------------
Windows 加入 FreeIPA 域
木子并不推荐通过 FreeIPA 管理 Windows 计算机,除非仅需统一管理少量 Windows Server。对于大规模的桌面终端,建议优先使用 Windows Active Directory 进行 LDAP 认证和计算机管理。因此,木子暂不计划撰写相关内容。如您有此需求,可参考以下文章链接:
[1] Windows_authentication_against_FreeIPA — FreeIPA documentation
[2] Implementing FreeIPA in a mixed Environment (Windows\Linux) – Step by step — FreeIPA documentation
参考文献
[1] Chapter 41. Managing Hosts in IdM CLI | Managing IdM users, groups, hosts, and access control rules
[2] Chapter 4. Configuring SSSD to use LDAP and require TLS authentication | Configuring authentication and authorization in RHEL
