Gitolite git clone需要ssh密码

Dis*_*nty 4 git ssh github gitolite

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

效果很好:git clone gitolite @ servername:testing.git

请求密码git clone ssh://gitolite@servername/home/gitolite/repositories/testing.git

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

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

Dar*_*les 5

您需要使用类似的行设置~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
Run Code Online (Sandbox Code Playgroud)

随机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
Run Code Online (Sandbox Code Playgroud)

编辑:反映您的编辑将'git'更改为'gitolite'系统用户名.

使用以下方法测试客户端的访问权限

ssh -l gitolite -i <file_id_rsa_foobar> -v -o PasswordAuthentication=no -T <host>
Run Code Online (Sandbox Code Playgroud)

我的本地系统似乎需要添加-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
....
Run Code Online (Sandbox Code Playgroud)