git - 龟GIT + Gitolite 3

标签 git ssh gitolite tortoisegit

我刚刚在 debian 上设置了 git + Gitolite 服务器,使用 puttygen 在我的工作站(Windows)上生成了 key 对,并在服务器上使用注册了第一个 pub key

gitosis setup -pk firstuser.pub

然后我使用 TortoiseGit 克隆 gitolite-admin 存储库,使用 url:[email protected] :gitolite-admin 和 tel Tortoise 使用firstuser.ppk 作为私钥。 到目前为止它工作正常。

然后我想测试添加用户并在我的工作站上创建新的存储库。

我在conf文件中添加了一个部分:

repo testcreation
    RW+     =   seconduser

我在我的工作站上为第二个用户生成了第二个 ssh key 对。只需将 secondaryuser.pub 放入 keydir/commit 中并推送新配置即可。

配置seam没问题,我的新用户pub key添加到服务器端git用户的~/.ssh/authorized_keys中。

我使用 Tortoise 在我的工作站上设置了一个新的存储库,添加了一个新的 Remote :

 name : origin
 url : <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e79776a5e79776a3073676d7b6c68307d7173" rel="noreferrer noopener nofollow">[email protected]</a>:testcreation
 Putty Key : seconduser.ppk

然后推送创建存储库

TortoiseGit Log :

git.exe push --all --progress  "origin"

FATAL: W any testcreation firstuser DENIED by fallthru
(or you mis-spelled the reponame)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


git did not exit cleanly (exit code 128) (1591 ms @ 12/02/2014 12:20:17)

当我发送 senconduser 私钥时,为什么 Gitolite 将我识别为firstuser?这与我在同一工作站上使用两个不同的 key 有关吗?

最佳答案

好吧,我找到了解决问题的方法。

请注意,我的工作站在 Windows 下

事实上,TortoiseGit 并没有使用 OpenSSH 作为 SSH 客户端,而是使用 Putty。在我的情况下,这确实很麻烦,因为带有 Plink (putty) 的 TortoiseGit 无法处理 2 个私钥来验证来自同一工作站的 2 个不同的 Gitolite 用户到单个 user@host (在我的情况下,firstuser 和 secondaryuser )使用 putty 作为 ssh 客户端。

请注意,在现实生活中,您可能不需要在同一工作站上使用 2 个不同的 ssh 身份验证,我只需要它来进行“测试”。

问题是 putty 是,据我所知,为每个 user@host ( [email protected] ) 注册 1 个 key ,我需要两个 key ......我在使用 git bash (和 openSSH)使用 ssh 配置后发现了这一点文件在 %HOMEDRIVE%%HOMEPATH%\.ssh\config

这是我的配置:

Host gitfirstuser
HostName git.myserv.com
User git
IdentityFile ~/.ssh/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="61070813121514120413210608154f0c18120413174f020e0c" rel="noreferrer noopener nofollow">[email protected]</a>

Host gitseconduser
HostName git.myserv.com
User git
IdentityFile ~/.ssh/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="364553555958524345534476515f42185b4f455344401855595b" rel="noreferrer noopener nofollow">[email protected]</a>

哪里<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="17717e6564636264726557707e63397a6e647265613974787a" rel="noreferrer noopener nofollow">[email protected]</a><a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e7d6b6d61606a7b7d6b7c4e69677a2063777d6b7c78206d6163" rel="noreferrer noopener nofollow">[email protected]</a>是 OpenSSH key 格式的私钥文件

之后,我可以克隆 testcreation.git使用 git bash 没有任何问题

git clone gitseconduser:testcreation

所以推、 pull 等等......

但是当你有一些 GUI 迷时,git bash 简直就是一场噩梦,所以这里是 TortoiseGit 中的解决方案,让它使用真正的 ssh 客户端:

打开 TortoiseGit 设置:

> Network section > SSH Client input > Browse...

在 msysgit 安装目录中查找 ssh.exe,就我而言:

C:\Program Files\Git\bin\ssh.exe

将 ssh 客户端更改为 ssh.exe 后,您就可以充分利用 ssh 配置文件。

例如:

在你的%HOMEDRIVE%%HOMEPATH%\.ssh\config

Host ssh_host_1
HostName git.myserv.com
User git
IdentityFile ~/.ssh/ssh_host_1_keyfile

在 TortoiseGit 中添加远程或克隆时使用以下 url:

ssh_host_1:repository_name

无需寻找私钥文件,openssh会根据ssh_host_1进行识别部分

关于git - 龟GIT + Gitolite 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21726745/

相关文章:

file-permissions - apache 权限被拒绝 : exec of '/usr/sbin/suexec2' failed

git - 通过build.gradle任务在项目目录中创建version.txt文件

ssh - 在VT100 SSH session 流中检测控制台提示

java - 使用JSCH执行软件远程安装

linux - 打开与 ssh-s 注销的数量一样多的终端,并关闭 ssh-s 注销的终端

git - TeamCity 从 SSH Git 存储库获取更改时如何解决超时异常

xcode - 如何在 Xcode 7 项目中包含 ReactiveCocoa 3.0

java - 使用 java 代码从 GIT url 检索分支

python - 如何从 check-yaml git hook 中排除 !Ref 标签?

gitolite(版本 3),更新管理 key