2012-08-03 171 views
3

我们正在试图建立代码审查的格里特实例,并计划使用“回购”在 我能够直接推动到格里特。 ,但使用repo upload失败公钥错误:调试“回购上传”的问题 - 权限被拒绝(公钥)

[email protected]:~/workspace/git/gerrit-test$ repo upload 
Upload project path/gerrit_test/ to remote branch master: 
branch master (1 commit, Fri Aug 3 15:23:50 2012 -0700): 
    8ef17a1b this better effin work 
to gerrit.test.com:8081 (y/N)? y 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 

---------------------------------------------------------------------- 
[FAILED] path/gerrit_test/ master   (Upload failed) 

我已经缩小的问题正被用于此回购的用户名,但不知道在哪里设置这个用户名(我不是确定如何检查正在使用的用户名)。 我已经尝试在.repo/manifests.git/config中添加以下内容,但仍然失败。

[review "gerrit.test.com:8081"] 
     username = <my_username_from_gerrit_profile_page> 

我在哪里添加正确的用户名?

谢谢。

+0

仅供参考,调试这和看的好办法的能力URL(包括用户名)'repo upload'正在使用'GIT_TRACE = 1 repo upload'。 – sschuberth 2016-07-26 13:55:03

回答

2

默认情况下,gerrit ssh服务器在端口29418上启动。您似乎正在连接到端口8081,我怀疑它是Web服务器端口号。

为了确认检查“等/ gerrit.config”文件的以下部分:

$ ssh -p 29418 [email protected] 

    **** Welcome to Gerrit Code Review **** 

    Hi mark, you have successfully connected over SSH. 

    Unfortunately, interactive shells are disabled. 
    To clone a hosted Git repository, use: 

    git clone ssh://[email protected]_machine:29418/REPOSITORY_NAME.git 

Connection to localhost closed. 

我:

[sshd] 
    listenAddress = *:29418 
[httpd] 
    listenUrl = http://*:8081/ 

你还可以通过运行以下命令来检查你的私钥证书认为你能够“直接推送到Gerrit”的原因是因为ssh端口号是存储库URL的一部分。

+0

谢谢。当我两周后回来工作时,我会试试这个报告。 – copolii 2012-08-06 19:03:32

+0

@copolii享受你的假期:-) – 2012-08-06 20:01:25

6

确保你的用户名在配置文件中。

$ git config --global review.<"URL">.username $USER 
+0

这真的很尴尬,这在大多数情况下确实是必要的,因为[默认情况下回购使用用户电子邮件地址作为用户名](https://android.googlesource.com/tools/repo /+/v1.12.33/git_config.py#652)而不是本地用户帐户的名称。 – sschuberth 2016-07-26 13:37:32

2

回购工具使用您的电子邮件前缀review.URL.username

例如,

用户名:john_chen

电子邮件[email protected]

John_Chen将是review.URL.username。

因此,你必须检查是否有通过John_Chen

连接

您可以通过回购跟踪此--trace上传