Gitolite git clone 需要 ssh 密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12467293/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:30:40  来源:igfitidea点击:

Gitolite git clone requires ssh password

gitsshgithubgitolite

提问by Dishcandanty

using Gitolite on a Ubuntu server. Have a project im working on that i need a particular syntax for the git command.

在 Ubuntu 服务器上使用 Gitolite。有一个我正在处理的项目,我需要 git 命令的特定语法。

Works great:

效果很好:

git clone gitolite@servername:testing.git

Asks for a password

要求输入密码

git clone ssh://gitolite@servername/home/gitolite/repositories/testing.git

Ran from the same box, one after another. I can put in the password and it works. But I need to automatically work. Sounds like a problem with ssh pub/private keys. Any ideas?

一个接一个地从同一个盒子里跑出来。我可以输入密码,它可以工作。但我需要自动工作。听起来像是 ssh pub/private 密钥的问题。有任何想法吗?

Update: Was a problem with file permissions. Not sure the difference between the too commands. But the /var/log/auth.logshowed some errors

更新:文件权限有问题。不确定 too 命令之间的区别。但是/var/log/auth.log显示了一些错误

回答by Darryl Miles

You need to setup ~gitolite/.ssh/authorized_keys with a line like

您需要使用类似的行设置 ~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

A random URL with info relating to this (see the bottom of the page)

包含与此相关的信息的随机 URL(请参阅页面底部)

http://www.geekgumbo.com/2011/10/18/ssh-and-the-gitolite-installation-part-2/

http://www.geekgumbo.com/2011/10/18/ssh-and-the-gitolite-installation-part-2/

Ensure to change ownership of ~gitolite/.ssh/authorized_keys as per SSH requirements with:

确保根据 SSH 要求更改 ~gitolite/.ssh/authorized_keys 的所有权:

chown gitolite: ~gitolite/.ssh/authorized_keys
chmod go-w ~gitolite/.ssh/authorized_keys

EDIT: to reflect your edits changing 'git' to 'gitolite' system username.

编辑:反映您将“git”更改为“gitolite”系统用户名的编辑。

Test your access from the client with:

使用以下命令测试您从客户端的访问:

ssh -l gitolite -i <file_id_rsa_foobar> -v -o PasswordAuthentication=no -T <host>

Added -T seems needed on my local system to get banner (typed in excuse mistakes):

在我的本地系统上似乎需要添加 -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
....

回答by VonC

If the first version works, that means the public keys have been published under the account named 'gitolite': ~gitolite/.ssh/authorized_keys.

如果第一个版本有效,则意味着公钥已在名为 ' gitolite':的帐户下发布~gitolite/.ssh/authorized_keys

The permission issue you have encountered is described here: "Creating SSH keys for Gerrit and Hudson": note that allthe parent directories of a .ssh shouldn't have write permission for group or other: /home, /home/yourUser, /home/yourUser/.ssh.

您遇到的权限问题在此处描述:“为 Gerrit 和 Hudson 创建 SSH 密钥”:请注意,.ssh 的所有父目录不应具有组或其他的写权限:/home, /home/yourUser, /home/yourUser/.ssh

Plus, you shouldn't ever clone a gitolite repo with the full path of the repo: servername/home/gitolite/repositories/testing.gitis wrong (and would by-pass gitolite completely).
servername:testing.gitis right.

另外,你永远不应该克隆一个带有完整路径的 gitolite 存储库:servername/home/gitolite/repositories/testing.git是错误的(并且会完全绕过 gitolite)。
servername:testing.git是对的。

From the gitolite V2 doc:

来自gitolite V2 文档

The following problem(s) indicate that your pubkey is bypassing gitolite and going straight to a shell

running git clone git@server:repositories/reponame(note presence of repositories/in URL) works.

[A proper gitolite key will only let you git clone git@server:reponame(note absence of repositories/)]

以下问题表明您的公钥正在绕过 gitolite 并直接进入 shell

运行git clone git@server:repositories/reponame(注意repositories/URL 中的存在)有效。

[一个合适的 gitolite 键只会让你 git clone git@server:reponame(注意没有repositories/)]

回答by kaleissin

Yet another thing to try: if AllowGroups is in use for the sshd on the server, check that the git-user is included in one of those groups.

还有一件事要尝试:如果服务器上的 sshd 正在使用 AllowGroups,请检查 git-user 是否包含在其中一个组中。