我刚刚在debian上设置了一个git + Gitolite服务器,用puttygen在我的工作站(Windows)上生成了一个密钥对,并在服务器上注册了第一个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
然后推送创建回购
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)
当我发送传感器私钥时,为什么Gitolite会将我识别为第一位用户?是否与我在同一工作站上使用两个不同的密钥有关?
答案 0 :(得分:4)
好吧,我发现了如何解决我的问题。
请注意我的工作站位于Windows
下事实是,TortoiseGit没有使用OpenSSH作为SSH客户端而是使用Putty。在我的情况下真的很烦,因为带有Plink(putty)的TortoiseGit 无法处理2个私钥来验证从同一个工作站到单个用户@主机的2个不同的Gitolite用户(在我看来是firstuser和seconduser) )使用putty作为ssh客户端。
请注意,在现实生活中,您可能不需要在同一个工作站上使用2个不同的ssh身份验证,我只需要进行“测试”。
问题是putty,据我所知,每个用户注册1个密钥@ host(git@git.myserv.com),我需要两个密钥......我在使用git bash(和openSSH)之后想出来了)使用%HOMEDRIVE%%HOMEPATH%\.ssh\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
其中firstuser@git.myserv.com
和seconduser@git.myserv.com
是OpenSSH密钥格式的私钥文件
之后,我可以使用testcreation.git
git bash
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
部分进行识别