備註:
- 此教學課程位於 Oracle 提供的免費實驗室環境。
- 它使用 Oracle Cloud Infrastructure 證明資料、租用戶及區間的範例值。完成實驗室之後,請將這些值取代為您雲端環境特有的值。
在 Oracle Linux 上安裝 FreeIPA 伺服器
簡介
FreeIPA 是 Linux 網路環境的開放原始碼識別與認證管理系統。伺服器包含「389 目錄伺服器」作為中央資料存放區,提供完整的多重主要 LDAPv3 功能。
除了本教學課程的範圍之外,FreeIPA 也透過 ISC Bind 伺服器提供 MIT Kerberos 進行單一登入認證、Dogtag Certificate Authority 以及選擇性的網域名稱管理。
本教學課程說明如何安裝 FreeIPA 和設定內含的 LDAP 目錄。
目標
- 安裝 FreeIPA 伺服器
- 停用匿名連結
- 新增使用者和群組
軟硬體需求
- 至少已安裝 2 vCPUs、2GB RAM 和 Oracle Linux 的系統
- 指向您伺服器 IP 位址的 FQDN (完整網域名稱)
如需有關 FreeIPA 需求的詳細資訊,請參閱上游的快速入門指南。
設定實驗室環境
注意:使用免費實驗室環境時,請參閱 Oracle Linux Lab Basics 以瞭解連線和其他使用指示。
-
開啟終端機,然後透過 ssh 連線到 freeipa-server 執行處理 (如果尚未連線)。
ssh oracle@<ip_address_of_instance>
確認伺服器 HostName
FreeIPA 伺服器需要運作中的 DNS 組態。使用 ipa
命令行工具註冊的從屬端會透過 /etc/ipa/default.conf
檔案中定義的 xmlrpc_url
和 domain
參數查詢伺服器。
-
驗證伺服器的主機名稱。
sudo hostname
輸出不應傳回
localhost
或localhost6
。
確認完整網域名稱 (FQDN)。
FreeIPA 在 FQDN 的限制為安裝期間驗證的 64 個字元。如果 FQDN 超過 64 個字元,請使用 sudo hostnamectl set-hostname NAME
(其中 NAME
是 FQDN) 加以縮短。
-
驗證 FQDN 及其長度。
hostname -f
echo $(hostname -f) | wc -m
注意: FQDN 由
freeipa.<RND_SUBNET>.linuxvirt.oraclevcn.com
組成,其中<RND_SUBNET>
是以字母o
字首的 4 個字元隨機字串。
確認名稱解析。
-
取得伺服器的 IP 位址。
sudo ip addr show
範例輸出:
[oracle@freeipa ~]$ sudo ip addr show ... 2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:00:17:02:b3:9e brd ff:ff:ff:ff:ff:ff altname enp0s3 inet 10.0.0.150/24 brd 10.0.0.255 scope global dynamic noprefixroute ens3 valid_lft 85923sec preferred_lft 85923sec inet6 fe80::200:17ff:fe02:b39e/64 scope link noprefixroute valid_lft forever preferred_lft forever
IPv4 位址顯示在以
inet
為開頭的行上。 -
驗證轉送 DNS 組態。
host $(hostname -f)
範例輸出:
[oracle@freeipa ~]$ host $(hostname -f) freeipa.o6fb5.linuxvirt.oraclevcn.com has address 10.0.0.150
驗證轉送 DNS 組態的另一個方式是使用
dig +short $(hostname -f) A
。host
和dig
都是bind-utils
套裝軟體的一部分,提供不同的公用程式來查詢 DNS 名稱伺服器。 -
確認反向 DNS 組態 (PTR 記錄)。
host $(hostname -i)
範例輸出:
[oracle@freeipa ~]$ host $(hostname -i) 150.0.0.10.in-addr.arpa domain name pointer freeipa.o6fb5.linuxvirt.oraclevcn.com.
或者使用
dig +short -x $(hostname -i)
。
開啟必要的防火牆連接埠
FreeIPA 需要開啟數個連接埠,才能與其服務進行通訊。
服務 | 連接埠 | 協定 |
---|---|---|
HTTP/HTTPS | 80,443 | TCP |
LDAP/LDAP | 389,636 | TCP |
Kerberos | 88,464 | TCP 和 UDP |
DNS | 53 | TCP 和 UDP |
NTP | 123 | UDP |
Oracle Linux 提供 freeipa-4
服務來開啟這些必要的連接埠。如需詳細資訊,請參閱 /usr/lib/firewalld/services/freeipa-4.xml
。freeipa-4
服務取代過時的 freeipa-ldap
和 freeipa-ldaps
服務。
-
新增
firewalld
服務。sudo firewall-cmd --permanent --add-service=freeipa-4
sudo firewall-cmd --reload
安裝必要的套裝軟體
-
在未使用整合式 DNS 服務的情況下安裝 FreeIPA 伺服器的套裝軟體。
sudo dnf install ipa-server -y
注意:此教學課程不使用整合的 DNS 服務。如有需要,請將套裝軟體
ipa-server-dns
增加到安裝清單中。
安裝和配置 FreeIPA 伺服器
-
執行安裝公用程式。
sudo ipa-server-install
命令檔會從提供安裝日誌檔位置和 FreeIPA 伺服器包含項目的摘要開始。
範例輸出:
[oracle@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 ...
程序檔接著使用數個提示來設定伺服器的配置。終端機會顯示括號內提示的預設回應,並按
Enter
接受預設回應。 -
接受
no
的預設回應以設定整合式 DNS 服務。Do you want to configure integrated DNS (BIND)? [no]:
-
接受預設主機名稱、網域名稱和範圍名稱。
這些是在實驗開始時驗證的值。建議範圍名稱與主要 DNS 網域名稱相同,且全為大寫字母。
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 [freeipa.o6fb5.linuxvirt.oraclevcn.com]: The domain name has been determined based on the host name. Please confirm the domain name [o6fb5.linuxvirt.oraclevcn.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 [O6FB5.linuxvirt.ORACLEVCN.COM]:
-
輸入並確認「目錄伺服器」超級使用者和 FreeIPA
admin
使用者的密碼。「目錄伺服器」超級使用者對應至目錄內的
cn=Directory Manager
。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): 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):
-
接受 NETBIOS 網域名稱的預設值並設定 chrony。
NetBIOS domain name [O6FB5]: Do you want to configure chrony with NTP server or pool address? [no]:
-
此命令檔會顯示伺服器組態的摘要。
-
輸入
yes
以接受伺服器組態。Continue to configure the system with these values? [no]: yes
-
程序檔會繼續配置伺服器。
這項作業可能需要幾分鐘的時間才能完成。
... Client configuration complete. The ipa-client-install command was successful Please add records in this file to your DNS system: /tmp/ipa.system.records.mv9i0ec2.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
完成時,程序檔會提供:
- 摘要。
- 要新增至 DNS 系統的記錄清單。
- 建議您備份產生的 CA 憑證。
已經使用
freeipa-4
firewalld
服務開啟必要的網路連接埠。
測試 FreeIPA 伺服器
FreeIPA 安裝包含命令行用戶端和 WebUI 以與伺服器互動。使用 WebUI 超出此教學課程的範圍。
存取命令行介面 (CLI)
-
對 Kerberos 範圍認證
admin
使用者。kinit admin
出現提示時,輸入安裝和組態步驟期間所建立之
admin
使用者的密碼。然後kinit
指令會產生一個 Kerberos 回報項目。 -
列出服務單的資訊
klist
範例輸出:
[oracle@freeipa ~]$ sudo klist Ticket cache: KCM:0 Default principal: admin@O6FB5.LINUXVIRT.ORACLEVCN.COM Valid starting Expires Service principal 09/28/2022 14:05:46 09/29/2022 13:05:53 krbtgt/O6FB5.LINUXVIRT.ORACLEVCN.COM@O6FB5.LINUXVIRT.ORACLEVCN.COM
-
取得 FreeIPA 伺服器上所有現有使用者的清單。
ipa user-find
結果會傳回
admin
使用者,這是目前唯一存在的使用者。範例輸出:
[oracle@freeipa ~]$ sudo ipa user-find -------------- 1 user matched -------------- User login: admin Last name: Administrator Home directory: /home/admin Login shell: /bin/bash Principal alias: admin@O6FB5.LINUXVIRT.ORACLEVCN.COM, root@O6FB5.LINUXVIRT.ORACLEVCN.COM UID: 872200000 GID: 872200000 Account disabled: False ---------------------------- Number of entries returned 1 ----------------------------
安全設定與強化
以下是一些安全地使用 FreeIPA 伺服器的方式。
停用匿名連結
FreeIPA LDAP 伺服器可啟用匿名連結作為預設值,因此會顯示特定的組態設定值和目錄值。
nsslapd-allow-anonymous-access
屬性控制此行為。可接受的值包括:
on
:允許所有匿名連結 (預設)rootdse
:僅允許根 DSE 資訊的匿名連結off
:不允許任何匿名連結
不允許匿名連結時,建議使用 rootdse
而非 off
,因為使用 off
也會阻止外部用戶端檢查伺服器組態。非網域從屬端 (例如 LDAP 和 Web 從屬端) 會透過讀取根 DSE 檔案來取得連線詳細資訊,以匿名方式連線。
-
檢查是否啟用匿名連結。
ldapsearch -x -h $(hostname -f) -b dc=$RND_SUBNET,dc=linuxvirt,dc=oraclevcn,dc=com
-x
設定簡單或匿名認證。-h
會設定 LDAP 伺服器主機。-b
會設定基礎 DN 以進行搜尋。
金鑰設定 (包括 FreeIPA 伺服器的基礎 DN) 儲存在
/etc/ipa/default.conf
檔案中。$RND_SUBNET
是免費實驗室環境中的環境變數集,代表 FQDN 中的 4 個字元隨機字串。範例輸出:
... # Default SMB Group, groups, accounts, o6fb5.linuxvirt.oraclevcn.com dn: cn=Default SMB Group,cn=groups,cn=accounts,dc=o6fb5,dc=linuxvirt,dc=oraclevc n,dc=com cn: Default SMB Group description: Fallback group for primary group RID, do not add users to this gr oup objectClass: top objectClass: ipaobject objectClass: posixgroup objectClass: ipantgroupattrs ipaUniqueID: 0c9cf178-4324-11ed-bf0b-02001704fe22 gidNumber: 921600001 ipaNTSecurityIdentifier: S-1-5-21-2697967063-3375457457-2974965896-1001 # search result search: 2 result: 0 Success # numResponses: 110 # numEntries: 109
搜尋結果會傳回 LDAP 目錄的整個樹狀結構。
-
修改組態並停用匿名連結。
ldapmodify
指令可接受含有進行變更的 LDIF 檔案,或從標準輸入讀取作業。-
建立 LDIF 檔案。
cat << 'EOF' | tee ~/disable_anon_bind.ldif > /dev/null dn: cn=config changetype: modify replace: nsslapd-allow-anonymous-access nsslapd-allow-anonymous-access: rootdse EOF
您可以變更多個屬性,方法是將它們以虛線
-
字元單獨分隔。每一項額外變更都從屬性變更類型開始,並提供所需的屬性。 -
套用 LDIF 變更。
ldapmodify -x -D "cn=Directory Manager" -W -H ldap:// -ZZ -f ~/disable_anon_bind.ldif
-x
設定簡單或匿名認證。-D
會設定連結 DN。-W
會提示輸入 LDAPadmin
密碼。-H
使用「LDAP 統一資源識別碼 (URI)」來連線,而非 LDAP 伺服器主機。-ZZ
會啟動 TLS 要求並強制成功回應。
注意:由於使用自行簽署的憑證,因此需要
-ZZ
。範例輸出:
[oracle@freeipa ~]$ ldapmodify -x -D "cn=Directory Manager" -W -H ldap:// -ZZ -f ~/disable_anon_bind.ldif Enter LDAP Password: modifying entry "cn=config"
-
重新啟動 FreeIPA 伺服器。
sudo systemctl restart ipa.service
-
-
匿名查詢目錄以驗證修改。
ldapsearch -x -h $(hostname -f) -b dc=$RND_SUBNET,dc=linuxvirt,dc=oraclevcn,dc=com
請注意回應
Anonymous access is not allowed
。範例輸出:
[oracle@freeipa ~]$ ldapsearch -x -h freeipa.o6fb5.linuxvirt.oraclevcn.com -b dc=o6fb5,dc=linuxvirt,dc=oraclevcn,dc=com # extended LDIF # # LDAPv3 # base <dc=o6fb5,dc=linuxvirt,dc=oraclevcn,dc=com> with scope subtree # filter: (objectclass=*) # requesting: ALL # # search result search: 2 result: 48 Inappropriate authentication text: Anonymous access is not allowed. # numResponses: 1
-
驗證使用認證來查詢目錄。
ldapsearch -D uid=admin,cn=users,cn=accounts,dc=$RND_SUBNET,dc=linuxvirt,dc=oraclevcn,dc=com -W -H ldap://
範例輸出:
... # freeipa.o6fb5.linuxvirt.oraclevcn.com + 389, subordinate-ids, dna, ipa, etc, o6fb5.linuxvirt.oraclevcn.com dn: dnaHostname=freeipa.o6fb5.linuxvirt.oraclevcn.com+dnaPortNum=389,cn=subord inate-ids,cn=dna,cn=ipa,cn=etc,dc=o6fb5,dc=linuxvirt,dc=oraclevcn,dc=com objectClass: dnaSharedConfig objectClass: top dnaHostname: freeipa.o6fb5.linuxvirt.oraclevcn.com dnaPortNum: 389 dnaSecurePortNum: 636 dnaRemainingValues: 32766 # search result search: 2 result: 0 Success # numResponses: 475 # numEntries: 474
確認 TLS 已啟用
從 Oracle Linux 8 開始,FreeIPA 使用全系統加密原則。如需詳細資訊,請參閱 crypto-policies(7)
線上手冊。
-
列出目前的全系統加密原則。
cat /etc/crypto-policies/config
-
列出加密原則詳細資訊。
cat /usr/share/crypto-policies/$(cat /etc/crypto-policies/config)/nss.txt
範例輸出:
[oracle@freeipa ~]$ cat /usr/share/crypto-policies/$(cat /etc/crypto-policies/config)/nss.txt library= name=Policy NSS=flags=policyOnly,moduleDB config="disallow=ALL allow=HMAC-SHA256:HMAC-SHA1:HMAC-SHA384:HMAC-SHA512:CURVE25519:SECP256R1:SECP384R1:SECP521R1:aes256-gcm:chacha20-poly1305:aes256-cbc:aes128-gcm:aes128-cb > c:SHA256:SHA384:SHA512:SHA224:ECDHE-RSA:ECDHE-ECDSA:RSA:DHE-RSA:ECDSA:RSA-PSS:RSA-PKCS:tls-version-min=tls1.2:dtls-version-min=dtls1.2:DH-MIN=2048:DSA-MIN=2048:RSA-MIN=2048"
請注意,
DEFAULT
原則最少使用TLS 1.2
。
檢查 FreeIPA 伺服器狀態
FreeIPA 伺服器包含 ipactl
公用程式,可檢視所設定服務的狀態。相同的公用程式也可以啟動、停止及重新啟動整個 FreeIPA 伺服器。如果您需要 start
、stop
或 restart
個別元件,請使用 systemctl COMMAND name.service
。
-
顯示所有服務的狀態 。
sudo ipactl status
範例輸出:
[oracle@freeipa ~]$ sudo ipactl status Directory Service: RUNNING krb5kdc Service: RUNNING kadmin Service: RUNNING httpd Service: RUNNING ipa-custodia Service: RUNNING pki-tomcatd Service: RUNNING ipa-otpd Service: RUNNING ipa: INFO: The ipactl command was successful
請使用
sudo ipactl --help
來查看其他指令選項。
建立使用者和群組
完成 FreeIPA 伺服器基本安裝和組態時,下一步是處理識別管理,其中包括建立使用者和群組。執行此動作之前,請先產生 Kerberos 記號。
-
產生使用者
admin
的記號。kinit admin
-
取得現有的權杖清單。
klist
Kerberos 記號預設為有效期 24 小時。由於先前已在標題為「存取指令行介面 (CLI)」的步驟中執行這些指令,因此清單會顯示原始記號,而不是建立新的記號。
-
新增使用者群組。
FreeIPA 會將使用者群組定義為一組具有標準密碼原則、權限及其他特性的使用者。
使用者群組可包含:
- 使用者
- 其他用戶組
- 存在於 FreeIPA 以外的外部使用者
ipa group-add foo
範例輸出:
[oracle@freeipa ~]$ ipa group-add foo ----------------- Added group "foo" ----------------- Group name: foo GID: 1326400003
FreeIPA 伺服器支援三種群組類型:
- POSIX (預設)
- 非 POSIX
- 外部
群組 foo
是 POSIX 使用者群組。若要指定不同的群組類型,請使用下列其中一個選項:
--nonposix
以建立非 POSIX 群組--external
以建立外部群組- 取得所有現有使用者群組清單。
ipa group-find
範例輸出:
[oracle@freeipa ~]$ ipa group-find ---------------- 5 groups matched ---------------- Group name: admins Description: Account administrators group GID: 1326400000 Group name: editors Description: Limited admins who can edit other users GID: 1326400002 Group name: foo GID: 1326400003 Group name: ipausers Description: Default group for all users Group name: trust admins Description: Trusts administrators group ---------------------------- Number of entries returned 5 ----------------------------
FreeIPA 伺服器會在安裝期間建立下列使用者群組。
admins
ipausers
trust admins
警告:請勿刪除
admin
群組,因為其中包含預設的admin
使用者。FreeIPA 伺服器需要admin
群組正確運作。
-
新增使用者帳戶。
ipa user-add
此命令會執行互動式命令檔,提示您最少的一組資料 FreeIPA 需要建立使用者帳戶。
範例輸出:
[oracle@freeipa ~]$ ipa user-add First name: Oracle Last name: User User login [ouser]: oracle ------------------- Added user "oracle" ------------------- User login: oracle First name: Oracle Last name: User Full name: Oracle User Display name: Oracle User Initials: OU Home directory: /home/oracle GECOS: Oracle User Login shell: /bin/sh Principal name: oracle@OD1F5.LINUXVIRT.ORACLEVCN.COM Principal alias: oracle@OD1F5.LINUXVIRT.ORACLEVCN.COM Email address: oracle@od1f5.linuxvirt.oraclevcn.com UID: 1326400004 GID: 1326400004 Password: False Member of groups: ipausers Kerberos keys available: False
另外,使用數個選項執行指令可讓您在非互動式模式下建立使用者帳戶。若要取得可用選項的清單,請執行
ipa user-add --help
。 -
將新使用者新增至新使用者群組。
ipa group-add-member foo --users=oracle
範例輸出:
[oracle@freeipa ~]$ ipa group-add-member foo --users=oracle Group name: foo GID: 1326400003 Member users: oracle ------------------------- Number of members added 1 -------------------------
ipa
指令的功能多於顯示的功能。如需使用其他指令,請執行 ipa help commands
以取得完整清單。
摘要
這包含此實驗室,其中介紹了安裝和使用 FreeIPA 伺服器的基本知識。使用以下連結進一步探索或閱讀產品手冊頁面,因為 FreeIPA 有許多其他功能,超出此處所涵蓋的內容。
其他相關資訊
檢視其他相關資源:
其他學習資源
瀏覽 docs.oracle.com/learn 的其他實驗室,或是存取 Oracle Learning YouTube 頻道上的更多免費學習內容。此外,造訪 education.oracle.com/learning-explorer 成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Install FreeIPA Server on Oracle Linux
F71514-01
October 2022
Copyright © 2022, Oracle and/or its affiliates.