附註:
- 本教學課程適用於 Oracle 提供的免費實驗室環境。
- 其使用 Oracle Cloud Infrastructure 證明資料、租用戶以及區間的範例值。完成實驗室時,請將這些值替代為雲端環境特定的值。
在 Oracle Linux 上安裝 FreeIPA 伺服器
簡介
FreeIPA 是一個開放原始碼的識別與認證管理系統,適用於 Linux 網路環境。伺服器包含 389 Directory Server 作為中央資料倉庫,提供完整的多主 LDAPv3 功能。
除了本教學課程的範圍之外,FreeIPA 也透過 ISC 連結伺服器提供用於單一登入認證的 MIT Kerberos、Dogtag 憑證授權機構以及選擇性的網域名稱管理。
本教學課程說明如何安裝 FreeIPA 並設定包含的 LDAP 目錄。
目標
在本自學課程中,您將學習如何:
- 安裝 FreeIPA 伺服器
- 停用匿名連結
- 新增使用者和群組
必要條件
-
最低單一 Oracle Linux 系統
-
每個系統都應安裝並設定 Oracle Linux,其中包含:
- 具有 sudo 存取權的非 root 使用者帳戶
- 存取 Internet。
- 指向您伺服器 IP 位址的 FQDN (完整網域名稱)
如需 FreeIPA 需求的詳細資訊,請參閱上游快速入門指南。
部署 Oracle Linux
注意:如果是在您自己的租用戶中執行,請先閱讀 linux-virt-labs GitHub 專案 README.md 並完成先決條件,再部署實驗環境環境。
-
在 Luna Desktop 上開啟終端機。
-
複製
linux-virt-labsGitHub 專案。git clone https://github.com/oracle-devrel/linux-virt-labs.git -
變更至工作目錄。
cd linux-virt-labs/ol -
安裝必要的集合。
ansible-galaxy collection install -r requirements.yml -
更新 Oracle Linux 執行處理組態。
cat << EOF | tee instances.yml > /dev/null compute_instances: 1: instance_name: "freeipa" type: "server" EOF -
部署實驗環境環境。
ansible-playbook create_instance.yml -e localhost_python_interpreter="/usr/bin/python3.6" -e "@instances.yml"自由實驗環境環境需要額外的變數
local_python_interpreter,此變數會設定在 localhost 上執行的播放ansible_python_interpreter。由於環境會安裝 Oracle Cloud Infrastructure SDK for Python 的 RPM 套件 (位於 python3.6 模組底下),因此需要此變數。預設部署資源配置使用 AMD CPU 和 Oracle Linux 8。若要使用 Intel CPU 或 Oracle Linux 9,請在部署命令中新增
-e instance_shape="VM.Standard3.Flex"或-e os_version="9"。重要事項: 請等待播放手冊順利執行,然後到達暫停工作。在手冊的這個階段,Oracle Linux 的安裝已完成,實例已就緒。記下先前的播放,此播放會列印其部署節點的公用和專用 IP 位址,以及執行實驗室時所需的任何其他部署資訊。
確認伺服器 DNS 組態
FreeIPA 伺服器需要有可用的 DNS 設定。使用 ipa 命令行工具註冊的從屬端,會依 /etc/ipa/default.conf 檔案中定義的 xmlrpc_url 和 domain 參數查詢伺服器。
-
開啟終端機,並透過 SSH 連線至 freeipa 執行處理。
ssh oracle@<ip_address_of_instance> -
確認伺服器的主機名稱。
sudo hostname輸出不應傳回
localhost或localhost6。
確認為完整網域的名稱 (FQDN)。
FreeIPA 的 FQDN 限制為 64 個字元,可在安裝期間進行驗證。如果 FQDN 超過 64 個字元,請使用 sudo hostnamectl set-hostname NAME (其中 NAME 是 FQDN) 來縮短 FQDN。
-
驗證 FQDN 及其長度。
hostname -f -
取得 FQDN 的長度
echo $(hostname -f) | wc -m
確認名稱解析。
-
取得伺服器 IP 位址。
ip -4 -o addr show ens3 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'其中
ens3是系統上網路介面的名稱。 -
請檢查轉送 DNS 組態。
host $(hostname -f)另一種驗證轉送 DNS 組態的方式是使用
dig +short $(hostname -f) A。host和dig都是bind-utils套裝軟體的一部分,提供不同的公用程式來查詢 DNS 名稱伺服器。 -
請檢查反向 DNS 組態 (PTR 記錄)。
host $(hostname -i)另一種方法是使用
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 |
| 新浪微博 | 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 -
重新載入 firewalld 服務,讓變更生效。
sudo firewall-cmd --reload
安裝必要的套裝程式
-
啟用 FreeIPA 模組串流和設定檔。
Oracle Linux 8:
sudo dnf module enable -y idm:DL1Oracle Linux 9 和 Oracle Linux 10:
由於 FreeIPA 套裝軟體是 AppStream 儲存庫的一部分,因此不需要在 Oracle Linux 9 上執行任何動作。
-
安裝沒有整合 DNS 服務之 FreeIPA 伺服器的套裝軟體。
sudo dnf install -y ipa-server備註:本教學課程不使用整合式 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.lv.vcn.oraclevcn.com]: The domain name has been determined based on the host name. Please confirm the domain name [lv.vcn.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 [LV.VCN.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 網域名稱和
no的預設值,以設定 chrony。NetBIOS domain name [LV]: 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-4firewalld服務開啟必要的網路連接埠。
測試 FreeIPA 伺服器
FreeIPA 安裝包含命令行用戶端和用於與伺服器互動的 WebUI。使用 WebUI 在本教學課程的範圍之外。
存取控制介面 (CLI)
-
對 Kerberos 範圍認證
admin使用者。kinit admin出現提示時,請輸入安裝和組態步驟期間所建立之
admin使用者的密碼。然後,kinit命令會產生 Kerberos 許可證。 -
列出票券的資訊
klist輸出範例:
[oracle@freeipa ~]$ sudo klist Ticket cache: KCM:0 Default principal: admin@LV.VCN.ORACLEVCN.COM Valid starting Expires Service principal 09/28/2022 14:05:46 09/29/2022 13:05:53 krbtgt/LV.VCN.ORACLEVCN.COM@LV.VCN.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@LV.VCN.ORACLEVCN.COM, root@LV.VCN.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 也會阻止外部用戶端檢查伺服器組態。讀取根 DSE 檔案以取得連線詳細資訊,以匿名方式連線非網域從屬端 (例如 LDAP 和 Web 從屬端)。
-
檢查是否啟用匿名連結。
ldapsearch -x -h $(hostname -f) -b dc=lv,dc=vcn,dc=oraclevcn,dc=com-x設定簡單或匿名驗證。-h設定 LDAP 伺服器主機。-b會設定搜尋的基礎 DN。
金鑰設定值 (包括 FreeIPA 伺服器的基礎 dn) 儲存在
/etc/ipa/default.conf檔案中。輸出範例:
... # Default SMB Group, groups, accounts, lv.vcn.oraclevcn.com dn: cn=Default SMB Group,cn=groups,cn=accounts,dc=lv,dc=vcn,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=lv,dc=vcn,dc=oraclevcn,dc=com請注意回應
Anonymous access is not allowed。輸出範例:
[oracle@freeipa ~]$ ldapsearch -x -h freeipa.lv.vcn.oraclevcn.com -b dc=lv,dc=vcn,dc=oraclevcn,dc=com # extended LDIF # # LDAPv3 # base <dc=lv,dc=vcn,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=lv,dc=vcn,dc=oraclevcn,dc=com -W -H ldap://輸出範例:
... # freeipa.lv.vcn.oraclevcn.com + 389, subordinate-ids, dna, ipa, etc, lv.vcn.oraclevcn.com dn: dnaHostname=freeipa.lv.vcn.oraclevcn.com+dnaPortNum=389,cn=subord inate-ids,cn=dna,cn=ipa,cn=etc,dc=lv,dc=vcn,dc=oraclevcn,dc=com objectClass: dnaSharedConfig objectClass: top dnaHostname: freeipa.lv.vcn.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 -
取得現有的記號清單。
klistKerberos 記號預設有效期為 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 伺服器會在安裝期間建立下列使用者群組。
adminsipauserstrust 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@LV.VCN.ORACLEVCN.COM Principal alias: oracle@LV.VCN.ORACLEVCN.COM Email address: oracle@lv.vcn.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 。