OpenLDAP 的細節設定 === ###### tags: `LDAP` ###### tags: `LDAP`, `OpenLDAP`, `Linux`, `Ubuntu`, `docker container`, `Kubernetes`, `K8s`, `pod`, `-ZZ`, `StartTLS`, `憑證`, `自簽憑證` <br> [TOC] <br> ## [docs] sssd-ldap(5) - Linux man page > https://linux.die.net/man/5/sssd-ldap ### `ldap_id_use_start_tls` (boolean, Default: `false`) Specifies that the id_provider connection must also use tls to protect the channel. <br> ### `ldap_tls_reqcert`(string, Default: `hard`) 指定在 TLS 工作階段中,要對伺服器憑證進行哪些檢查(若有)的設定。 > Specifies what checks to perform on server certificates in a TLS session, if any. It can be specified as one of the following values: - **`never` = 客戶端不會要求或檢查任何伺服器憑證。** > The client will not request or check any server certificate. - **`allow` = 會要求伺服器提供憑證;若未提供,連線照常進行。若提供了無效(不受信任)的憑證,會被忽略,連線仍照常進行。** > The server certificate is requested. If no certificate is provided, the session proceeds normally. If a bad certificate is provided, it will be ignored and the session proceeds normally. - **`try` = 會要求伺服器提供憑證;若未提供,連線照常進行。若提供了無效(不受信任)的憑證,連線會立即中止。** > The server certificate is requested. If no certificate is provided, the session proceeds normally. If a bad certificate is provided, the session is immediately terminated. - **`demand` = 會要求伺服器提供憑證;若未提供或提供了無效(不受信任)的憑證,連線會立即中止。** > The server certificate is requested. If no certificate is provided, or a bad certificate is provided, the session is immediately terminated. - `hard` = 與「demand」相同。 <br> ### access_provider = permit > 存取控制(Access Control) - 預設允許所有目錄中可解析的帳號登入 <br> --- <br> ## [docs] Using sssd in a Playground Without TLS > https://www.analogous.dev/blog/sssd-without-tls/?utm_source=chatgpt.com ### `ldap_auth_disable_tls_never_use_in_production`(boolean,Default: `false`) **說明:** 這是一個 *未在官方 man page 中文件化* 的隱藏選項,用來「強制關掉 SSSD 在 LDAP 驗證(simple bind)時一定要走 TLS」的安全限制。 * 設為 `false`(預設): * SSSD **拒絕** 在 *未加密* 的 LDAP 連線上做密碼驗證(simple bind),也就是不允許在 `ldap://` 明文連線上送出帳號密碼。這是正常且建議的安全行為。([mail-archive.com](https://www.mail-archive.com/sssd-devel%40lists.fedorahosted.org/msg05259.html?utm_source=chatgpt.com)) * 設為 `true`: * 允許 SSSD 在 **沒有 TLS 保護的 LDAP 連線** 上執行 simple bind 驗證,也就是可以在 `ldap://host:389`、未啟用 `StartTLS` 的情況下,直接用帳號密碼登入。([nbari.com](https://nbari.com/ldap-auth-disable-tls-never-use-in-production/)) * 這會讓使用者帳號與密碼在網路上「明文傳輸」,非常容易被封包攔截或中間人攻擊(MITM),安全風險極高。([Red Hat Docs](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_authentication_and_authorization_in_rhel/configuring-sssd-to-use-ldap-and-require-tls-authentication_configuring-authentication-and-authorization-in-rhel)) > 此選項的原始補丁說明很白話:**「允許 SSSD 在沒有 TLS 通道的情況下執行 LDAP simple-bind authentication」**,並且作者特別強調,這個選項只為了測試/特殊需求存在,**絕對不應該用在正式環境**。([mail-archive.com](https://www.mail-archive.com/sssd-devel%40lists.fedorahosted.org/msg05259.html?utm_source=chatgpt.com)) --- #### 什麼時候會看到人用它? * 教學或「Playground / Lab」環境: * 例如官方部落格示範「在 *玩具環境* 中用 SSSD 連線到只開 389 明文 LDAP 的 OpenLDAP 容器」,會搭配: * `ldap_uri = ldap://…:389` * `ldap_id_use_start_tls = false` * `ldap_auth_disable_tls_never_use_in_production = true` * 作者也在文中用大寫註明:**不要在任何「真實」環境使用這個設定**。([Analogous](https://www.analogous.dev/blog/sssd-without-tls/)) * 某些特定文件(如 AWS ParallelCluster + Managed AD)會要求在 **高度受控的環境** 中設成 `true`,但那通常假設你另外有 VPN、私有網路或其它層級的保護。([AWS Documentation](https://docs.aws.amazon.com/zh_tw/parallelcluster/latest/ug/create-addircluster-v3.html)) --- #### 實務上的建議(重點) 1. **正式環境(Production):** * 不要使用這個選項,維持預設 `false`。 * 請正確設定 TLS/StartTLS,並用受信任的憑證(或正確安裝自簽 CA)。 2. **教學/實驗/本機練習:** * 若只是為了「先讓 SSSD 跑起來」、在短時間內測試 LDAP schema 或 sssd 設定,可暫時使用: ```ini [domain/default] id_provider = ldap auth_provider = ldap ldap_uri = ldap://ldap.example.test:389 ldap_id_use_start_tls = false ldap_auth_disable_tls_never_use_in_production = true ``` * 但要清楚知道: * 密碼是明文在網路上跑。 * 一旦搬到任何實際環境,就應該**立刻移除**這個設定,改成啟用 TLS / StartTLS。 <br> {%hackmd vaaMgNRPS4KGJDSFG0ZE0w %}