我認為我對我想要實現的目標有一些理解問題...
那麼,讓我們從目前正在運行的內容開始(所有描述的伺服器都運行 CentOS 7):
- 包含使用者公鑰的 OpenLDAP 伺服器
- 運行 OpenSSH 守護程序的「資料」伺服器,允許使用者透過私鑰進行連線(使用 ssh 命令)
現在,我的最終目標:
- gitolite 服務(在「資料」伺服器上),從 OpenLDAP 伺服器取得使用者的公鑰
(幾個 contrib 腳本 - 查詢基於 IPA 的 LDAP 伺服器以取得群組成員資格和使用者金鑰管理)
所以我認為有可能實現我想要的,但我不知道如何...
我讀過也可以查詢 LDAP 伺服器取得群組資訊。所以我想相信可以用公鑰做同樣的事情。
我瀏覽了很多鏈接,但找不到解決我的問題的東西...如果有人給我,哪怕是一點提示,那就太好了:)
祝你今天過得愉快 !
PS:只是想補充一點,我並不害怕讀/寫大量程式碼。如果您的解決方案是使用 gitolite 以外的其他東西,這也不是問題,即使保留 gitolite 更適合個人目的。
編輯1:
這就是目前的運作方式:
當我嘗試使用以下命令克隆預設的testing.git存儲庫時:
git clone ssh://git@dataserver/testing.git
與以下〜/ .ssh /配置:
host dataserver
hostname dataserver
Identityfile ~/.ssh/user
User git
我的終端告訴我:
Cloning in 'testing'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
但是如果我的資料夾中有我的使用者(user.pub)的公鑰keydir
,那麼一切都很好:
git clone ssh://git@dataserver/testing.git
Cloning in 'testing'...
Enter passphrase for key '/home/user/.ssh/user_rsa:
warning: it seems that you've cloned a bare repository.
Verifying connectivity... done.
git 儲存庫在這裡:
ls -l | grep testing
drwxrwxr-x 3 user user 4096 mars 23 11:03 testing
編輯2:
我只是添加我的資料伺服器如何查詢 OpenLDAP 以獲取用戶的公鑰(以防萬一)。
/etc/ssh/sshd_config :
AuthorizedKeysCommand /usr/bin/ssh-keyldaps %u
AuthorizedKeysCommandUser nobody
/usr/bin/ssh-keyldaps :
ldapsearch -H ldaps://ldapserver \
-b dc=my,dc=domain \
-x -LLL \
-o ldif-wrap=no \
"(&(uid=$uid)(sshPublicKey=*))" 'sshPublicKey' |
sed -n 's/^sshPublicKey:\s*\(.*\)$/\1/p'
我排除了一些行,因為它們在這裡只是為了記錄目的。
由於此配置,所有在 LDAP 中註冊的使用者都sshPublicKey
可以透過其私鑰登入資料伺服器。
答案1
AuthorizedKeysCommand
因為這sshd_config
可能就是您想要查看的內容。文件片段讀起來就像 gitolite 沒有附帶任何東西,而是依賴外部因素。
sss_authorized_keys
例如,您可以設定 sssd 以針對 LDAP 伺服器進行身份驗證,然後使用。
文件應該很容易找到。