【问题标题】:Error: failed to push some refs to ssh without username错误:无法在没有用户名的情况下将一些参考推送到 ssh
【发布时间】:2017-03-03 23:56:16
【问题描述】:

由于此错误,我在将更改从 Jenkins 服务器推送到 Gerrit 服务器时遇到问题:

+ git checkout origin/release_6.3.0
Previous HEAD position was 6c1313da... Fixes getting secret posts when searching posts by market.
HEAD is now at a9490de6... Fixes channels routes.
+ git rev-parse Deploy_Stage_6.3.0_RC210_Her
+ git tag Deploy_Stage_6.3.0_RC210_Her
+ git push origin Deploy_Stage_6.3.0_RC210_Her
debug1: Connecting to gerrit [XX.XX.XX.X] port 29418.
debug1: Connection established.
debug1: identity file /c/Users/mikz/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/mikz/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_2.12 (SSHD-CORE-0.14.0)
debug1: no match: GerritCodeReview_2.12 (SSHD-CORE-0.14.0)
debug1: Authenticating to gerrit:29418 as 'gerrit'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group1-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: ssh-rsa SHA256:lZ41xRL6gg58lbJKSIcYDlo54lUVj6lUFOCsj1zfKns
debug1: Host '[gerrit]:29418' is known and matches the RSA host key.
debug1: Found key in /c/Users/mikz/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/USER_NAME/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to gerrit ([XX.XX.XX.X]:29418).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending command: git-receive-pack 'PATH'
remote: 
remote: Processing changes: refs: 1, done            
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2904, received 252760 bytes, in 0.9 seconds
Bytes per second: sent 3225.7, received 280757.7
debug1: Exit status 0
To ssh://gerrit:29418/PATH
 ! [remote rejected]   Deploy_Stage_6.3.0_RC210_Her -> Deploy_Stage_6.3.0_RC210_Her (prohibited by Gerrit)
error: failed to push some refs to 'ssh://gerrit@gerrit:29418/PATH'
Build step 'Conditional step (single)' marked build as failure
Description set: 
Finished: FAILURE

这可能是因为在这一行:

到 ssh://gerrit:29418/PATH

我没有用户名,但我不知道如何修复它

我在 .gitconfig 中添加了以下行,但它不起作用:
[网址“ssh://gerrit@gerrit:29418/”]
insteadOf = ssh://gerrit:29418/



知道如何解决这个问题吗?

【问题讨论】:

    标签: jenkins ssh gerrit


    【解决方案1】:

    当您执行“git push origin BRANCH”时,您会绕过 Gerrit 直接推送到分支。此错误(Gerrit 禁止)意味着“gerrit”用户无权执行此操作。您需要授予用户绕过代码审查的权限或在您的推送命令中使用“refs/for/BRANCH”。

    在 Gerrit 文档 here 中查看有关此错误的更多详细信息。

    【讨论】:

    • 用户“gerrit”在gerrit中拥有管理员权限
    • 只有 Gerrit 管理员是不够的。管理员已分配“管理服务器”功能,但默认情况下,他们没有所有推送/创建权限。您需要确保“gerrit”用户对“refs/heads/*”具有“推送”访问权限。还要检查我发布的链接中列出的所有其他权限。
    • 这是我为“refs/heads/*”prntscr.com/efke62 用户 gerrit 在管理员组中的 gerrit 设置的屏幕截图
    • >>>>在此处的 Gerrit 文档中查看有关此错误的更多详细信息。 gerrit-review.googlesource.com/Documentation/…这是正确答案。谢谢!
    【解决方案2】:

    Gerrit 中的权限错误。 所有权限都应根据 https://gerrit-review.googlesource.com/Documentation/error-prohibited-by-gerrit.html

    【讨论】:

    • 你为什么重复我已经发布的相同答案而不是接受我的答案?
    猜你喜欢
    • 2020-03-04
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多