简体   繁体   English

TortoiseGIT + Gitolite 3

[英]TortoiseGIT + Gitolite 3

I've just set up a git + Gitolite server on debian, generated a key pair on my workstation (Windows) with puttygen and register the first pub key using on the server 我刚刚在debian上设置了git + Gitolite服务器,并在我的工作站(Windows)上使用puttygen生成了密钥对,并在服务器上使用注册了第一个发布密钥

gitosis setup -pk firstuser.pub

Then I use TortoiseGit to clone the gitolite-admin repo, using url : git@git.myserv.com:gitolite-admin and tel Tortoise to use firstuser.ppk as private key. 然后,我使用TortoiseGit克隆gitolite-admin存储库,使用url:git@git.myserv.com:gitolite-admin和tel Tortoise将firstuser.ppk用作私钥。 It works fine until this point. 到目前为止,一切正常。

Then I want to test adding a user and creating a new repo on my workstation. 然后,我想测试添加用户并在工作站上创建新的存储库。

I add in the conf file a section : 我在conf文件中添加了一个部分:

repo testcreation
    RW+     =   seconduser

I generate on my workstation a second ssh key pair for seconduser. 我在工作站上为seconduser生成了第二个ssh密钥对。 Just put the seconduser.pub in keydir/ commit and push the new config. 只需将seconduser.pub放在keydir / commit中,然后推送新的配置即可。

Config seam to be alright, my new user pub key added to ~/.ssh/authorized_keys of the git user on server side. 配置接缝很好,我的新用户发布密钥已添加到服务器端git用户的〜/ .ssh / authorized_keys中。

I set up a new repo on my workstation with Tortoise, add a new remote : 我用Tortoise在我的工作站上设置了一个新的仓库,添加了一个新的遥控器:

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

And then push to create 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)

Why does Gitolite identify me as firstuser when I send the senconduser private key ? 当我发送senconduser私钥时,为什么Gitolite会将我标识为第一用户? Does it have something to do with the fact I use two different key on the same workstation ? 这与我在同一工作站上使用两个不同的密钥有关吗?

Well, I found out how to resolve my problem. 好吧,我找到了解决问题的方法。

Note that my workstation is under Windows 请注意,我的工作站在Windows下

The fact is, TortoiseGit is not using OpenSSH as SSH Client but Putty. 事实是,TortoiseGit不是使用OpenSSH作为SSH客户端,而是使用Putty。 It really is bothering in my case because TortoiseGit with Plink (putty) can not handle 2 private keys to authenticate 2 different Gitolite users from the same workstation to a single user@host (in my case firstuser and seconduser) using putty as ssh client. 在我的情况下,这确实令人不安,因为具有Plink(putty)的TortoiseGit 无法使用2个私有密钥来使用putty作为ssh客户端对同一工作站中的2个不同Gitolite用户进行身份验证,从而将其从同一工作站认证为单个user @ host(在我的情况下为firstuser和seconduser)。

Note that in real life, you probably won't need to use 2 different ssh authentification on the same workstation, I only needed that to do 'tests'. 请注意,在现实生活中,您可能不需要在同一工作站上使用2个不同的ssh身份验证,我只需要使用它来进行“测试”。

The issue is putty is, as far as I see, registering 1 key per user@host (git@git.myserv.com), I needed two key...I figured that out after using git bash (and openSSH) using ssh config file in %HOMEDRIVE%%HOMEPATH%\\.ssh\\config 据我所知,问题是腻子是每个用户@主机(git@git.myserv.com)注册1个密钥,我需要两个密钥...我发现在使用ssh使用git bash(和openSSH)之后%HOMEDRIVE%%HOMEPATH%\\.ssh\\config

Here is my config : 这是我的配置:

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

where firstuser@git.myserv.com and seconduser@git.myserv.com are private key file in OpenSSH key format 其中firstuser@git.myserv.comseconduser@git.myserv.com是OpenSSH密钥格式的私钥文件

After that, I could clone testcreation.git without any trouble using git bash 之后,我可以使用git bash testcreation.git地克隆testcreation.git

git clone gitseconduser:testcreation

and so push, pull, etc... 然后推,拉等

But when you have some GUI fanboy, git bash is just a nightmare, so here is the solution in TortoiseGit to make it use a REAL ssh client : 但是,当您有一些GUI迷时,git bash只是一场噩梦,因此下面是TortoiseGit中的解决方案,使其使用REAL ssh客户端:

Open TortoiseGit Settings : 打开TortoiseGit设置:

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

Look up for ssh.exe in msysgit installation directory, in my case : 在我的情况下,在msysgit安装目录中查找ssh.exe:

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

Once you changed the ssh client to ssh.exe you can fully take advantage of your ssh config file. 将ssh客户端更改为ssh.exe后,您就可以充分利用ssh配置文件。

For exemple : 举个例子 :

in your %HOMEDRIVE%%HOMEPATH%\\.ssh\\config 在您的%HOMEDRIVE%%HOMEPATH%\\.ssh\\config

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

In TortoiseGit when adding a remote, or cloning use the following url : 在TortoiseGit中,添加遥控器或进行克隆时,请使用以下网址:

ssh_host_1:repository_name

No need to look for a private key file, openssh will do the identification according to ssh_host_1 section 无需查找私钥文件,openssh将根据ssh_host_1部分进行标识

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM