【问题标题】:TortoiseGIT + Gitolite 3TortoiseGIT + Gitolite 3
【发布时间】:2014-02-12 22:09:39
【问题描述】:

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

gitosis setup -pk firstuser.pub

然后我使用 TortoiseGit 克隆 gitolite-admin repo,使用 url : git@git.myserv.com:gitolite-admin 和 tel Tortoise 使用 firstuser.ppk 作为私钥。 在此之前它工作正常。

然后我想测试添加一个用户并在我的工作站上创建一个新的 repo。

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

repo testcreation
    RW+     =   seconduser

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

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

我用 Tortoise 在我的工作站上设置了一个新的仓库,添加一个新的遥控器:

 name : origin
 url : git@git.myserv.com:testcreation
 Putty Key : seconduser.ppk

然后push创建repo

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 ?这与我在同一个工作站上使用两个不同的密钥有关吗?

【问题讨论】:

  • 您可以尝试使用git@git.myserv.com/testcreation 作为远程网址吗?
  • 好吧...致命:'git@git.myserv.com/testcreation' 似乎不是 git 存储库 =)
  • 好的。我提到它是因为 ':' 是 scp 符号,更好地与 ~/.ssh/config 文件结合使用,以便声明另一个密钥(如 stackoverflow.com/a/20139338/6309stackoverflow.com/a/19976522/6309
  • 好吧,如果我们的工作站在 Linux 下运行会简单得多,但幸运的是 Windows 的 OpenSSH 和 Msysgit 可以拯救我们,可怜的 M$ 用户^^
  • 我同意。我总是在 Windows 上使用 openssh,从不使用 putty。

标签: git ssh gitolite tortoisegit


【解决方案1】:

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

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

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

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

问题是腻子,据我所知,为每个用户@主机(git@git.myserv.com)注册 1 个密钥,我需要两个密钥......我在使用 git bash(和 openSSH ) 在%HOMEDRIVE%%HOMEPATH%\.ssh\config中使用ssh配置文件

这是我的配置:

Host gitfirstuser
HostName git.myserv.com
User git
IdentityFile ~/.ssh/firstuser@git.myserv.com

Host gitseconduser
HostName git.myserv.com
User git
IdentityFile ~/.ssh/seconduser@git.myserv.com

其中firstuser@git.myserv.comseconduser@git.myserv.com 是OpenSSH 密钥格式的私钥文件

之后,我可以使用 git bash 毫无问题地克隆 testcreation.git

git clone gitseconduser:testcreation

然后推、拉等等……

但是当你有一些 GUI 粉丝时,git bash 只是一场噩梦,所以这里是 TortoiseGit 中的解决方案,让它使用 REAL 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部分做识别

【讨论】:

  • 很好的详细答案。 +1
猜你喜欢
  • 1970-01-01
  • 2012-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多