调试'repo upload'问题 - 权限被拒绝(publickey)

时间:2012-08-03 23:15:31

标签: git repository gerrit

我们正在尝试为代码审查设置Gerrit实例,并计划在其中使用'repo'。 我可以将直接推送到Gerrit ,但使用repo upload失败并出现公钥错误:

user@machine:~/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的用户名,但不知道在哪里设置此用户名(我不知道如何检查正在使用的用户名)。 我已尝试在 .repo / manifests.git / config 中添加以下内容,但仍然失败。

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

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

感谢。

3 个答案:

答案 0 :(得分:8)

确保您的配置文件中包含您的用户名。

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

答案 1 :(得分:2)

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

要确认,请查看“etc / gerrit.config”文件的以下部分:

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

您还可以通过运行以下命令来检查您的私钥凭据:

$ ssh -p 29418 your_user_id@localhost

  ****    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://your_user_id@your_machine:29418/REPOSITORY_NAME.git

Connection to localhost closed.

我认为您能够“直接推送到Gerrit”的原因是因为ssh端口号是存储库URL的一部分。

答案 2 :(得分:2)

repo工具使用您的电子邮件的前缀作为review.URL.username

例如,

用户名:john_chen

电子邮件:John_Chen@gmail.com

John_Chen 将是review.URL.username。

因此,你必须检查你是否有能力通过John_Chen连接

您可以通过 repo --trace upload

进行追踪
相关问题