[英]Gitolite git clone requires ssh password
在Ubuntu服務器上使用Gitolite。 有一個項目即時通訊正在工作,我需要git命令的特定語法。
效果很好:
git clone gitolite@servername:testing.git
要求輸入密碼
git clone ssh://gitolite@servername/home/gitolite/repositories/testing.git
從同一個盒子跑,一個又一個。 我可以輸入密碼,它可以正常工作。 但是我需要自動工作。 聽起來像是ssh pub /私有密鑰的問題。 有任何想法嗎?
更新 :文件權限存在問題。 不確定too命令之間的區別。 但是/var/log/auth.log
顯示了一些錯誤
您需要使用以下行來設置〜gitolite / .ssh / authorized_keys
command="/home/gitolite/bin/gl-auth-command <USERNAME>",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA...KEY.HERE...ZZZZ== user@label
帶有相關信息的隨機URL(請參閱頁面底部)
http://www.geekgumbo.com/2011/10/18/ssh-and-the-gitolite-installation-part-2/
確保根據SSH要求更改〜gitolite / .ssh / authorized_keys的所有權,方法是:
chown gitolite: ~gitolite/.ssh/authorized_keys
chmod go-w ~gitolite/.ssh/authorized_keys
編輯:反映您的更改,將'git'更改為'gitolite'系統用戶名。
使用以下方法測試來自客戶端的訪問權限:
ssh -l gitolite -i <file_id_rsa_foobar> -v -o PasswordAuthentication=no -T <host>
在我的本地系統上似乎需要添加-T來獲得標題(鍵入借口錯誤):
....
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/username/.ssh/id_rsa_foobar
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/username/.ssh/id_dsa_foobar
debug1: Remote: Forced command: /home/gitolite/bin/gl-auth/command <username>
....
hello <username> this is gitolite vX.X.XX-g0123abcd running on git X.X.X
the gitolite config gives you the following access:
R W mydir/project1
....
如果第一個版本有效,則意味着公鑰已在名為“ gitolite
”的帳戶下發布: ~gitolite/.ssh/authorized_keys
。
您遇到的權限問題在這里進行描述:“ 為Gerrit和Hudson創建SSH密鑰 ”:請注意,.ssh的所有父目錄都不應具有對group或其他權限的寫許可權: /home
, /home/yourUser
, /home/yourUser/.ssh
。
另外,您永遠都不應使用回購的完整路徑克隆一個gitolite回購: servername/home/gitolite/repositories/testing.git
是錯誤的(並且會完全繞過gitolite)。
servername:testing.git
是正確的。
以下問題表明您的公鑰繞過gitolite並直接進入外殼
運行
git clone git@server:repositories/reponame
(注意URL中存在repositories/
)有效。[正確的gitolite密鑰只能讓您git clone
git@server:reponame
(注意沒有repositories/
)]
還要嘗試的另一件事:如果服務器上的sshd使用AllowGroups,請檢查git-user是否包含在這些組之一中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.