FreeIPA 設定檔導致的 SSH 錯誤
前言
事情要說回到前兩週更新 Proxmox 集群時,在更新完成兩個節點後,有使用者回報發生無法打開虛擬機的錯誤,仔細查看後發現是 SSH 的錯誤,在其他節點的 Web UI 開啟另一個節點上虛擬機的 Console 會發生錯誤,不過當時猜測可能是因為集群沒有完整更新完成,部分節點仍停留在 PVE 8,因此暫時忽略。
在徹底更新完成整個集群後,又發現了有關 Migrate 的錯誤,遷移虛擬機時通通發生以下錯誤。
1 | |
問題
其實這個錯誤相當好解決。只要把上面兩排星號間的錯誤訊息在丟到 Google,就能立刻找到兩篇文章,一篇是對 SSSD 的 Bug report[1],一篇是抱怨 Debian 上的 FreeIPA 會導致更新後 SSH 出錯[2],這兩篇文章都提到了是sss_ssh_knownhostsproxy導致的問題。
在 SSSD 更新後(Proxmox/Debian 大版本更新),sss_ssh_knownhostsproxy這個指令被廢棄,轉向使用新的指令sss_ssh_knownhosts,但舊的指令仍然存在,只會回傳錯誤。
1 | |
之所以會使用到sss_ssh_knownhostsproxy指令是因為在ipa-client-install時會建立設定檔/etc/ssh/sshd_config.d/04-ipa.conf,其中就包括了透過 SSSD 查詢 ssh knownhost 的設定,參考 FreeIPA 設定與客戶端安裝過程 - 使用 FreeIPA-Client 驗證。
1 | |
解決
解決方法其實很簡單,就是把ProxyCommand的設定修正一下和註解GlobalKnownHostsFile就好
1 | |
修正後的內容如下
1 | |
深入
雖然問題很容易解決,不過我很好奇,為什麼更新會導致這種錯誤。
在第二篇文章中,有提到 #9536(FreeIPA 的 Issue 9536),並且4.12的 release note也有提到這個 Issue,而且特別說明在更新版本時會通過一種機制自動升級設定檔。
Deprecated sss_ssh_knownhostsproxy in favor of sss_ssh_knownhosts. With this update, if /usr/bin/sss_ssh_knownhosts is present, it will be used instead of /usr/bin/sss_ssh_knownhostsproxy. We implemented a mechanism to apply this change when upgrading from older versions, and downgrading from newer versions.
我翻了一下 Issue 的內容,找到了 a41e5e2 這個 Commit,在這個 Commit 中修改了 spec file,增加了判斷 SSSD 是否升級的邏輯,如果升級了,就把設定檔用sed取代成新的樣式,反之取代成舊的樣式。
但問題是, spec file 是 RPM 打包時的設定檔案之一,它只適用於 RPM-based system,而 Proxmox/Debian 是 DEB-based system, DEB 是用 deb control file 來做這種設定,但是打包時卻沒有將這部份的邏輯增加到 deb control 中。

目前先提了一個 Debian Bug report,看之後打包人員是否會納入修正吧,#1111396
參考
- 2305856 – sss_ssh_knownhosts man page does not contain information about replacements ↩
- FreeIPA on Devuan and sss ssh knownhosts proxy | Knowledge Base ↩
- Issue #9536: Client configuration of ssh: Replace sss_ssh_knownhostsproxy with sss_ssh_knownhosts - freeipa - Pagure.io ↩
- FreeIPA 4.12.0 — FreeIPA documentation ↩
- Commit - freeipa - a41e5e2a244f8fa2edfd7db1e821d8b0f3bbd997 - Pagure.io ↩
- #1111396 - freeipa-client: /etc/ssh/ssh_config.d/04-ipa.conf create before 4.12 make ssh error - Debian Bug report logs ↩