错误:项目/repo.git 的权限被拒绝以部署密钥



我正在尝试将 GitHub Enterprise 中的一个存储库设置为默认拉取源。在我们的项目中,每当我们推送一些更改时,Jenkins 都用于自动构建整个代码库。在我们在我们的项目空间使用本地安装的 GIT 之前。现在我们正在迁移到 GHE。

我在Configure>Source Code Management tab>Repository URL>git@github.com:project/repo所做的改变。

经过有力的Build Now,我们收到日志错误:

ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress git@github.com:project/repo +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:ZjDIk3kbdyojRjqiBBfXS6xOHF+y+9bzcbZypukADHA.
Please contact your system administrator.
Add correct host key in <jenkins_home>/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in <jenkins_home>/.ssh/known_hosts:49
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
X11 forwarding is disabled to avoid man-in-the-middle attacks.
ERROR: Permission to project/repo.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我在 Jenkins上没有任何读/写访问权限,并已要求我们的 Jenkins 管理员根据错误删除<jenkins_home>/.ssh/known_hosts处的第 49 行。

他这样做了,他也分享了我们id_rsa.pubid_ecdsa.pub。 已尝试将这些密钥添加为项目/存储库上的部署密钥。

  • id_rsa.pub我收到了一条Key is already in use消息。
  • 但是id_ecdsa.pub已成功添加为部署密钥。

但是我仍然收到一条错误消息:

Failed to connect to repository : Command "git ls-remote -h git@github.com:project/repo HEAD" returned status code 128:
stdout: 
stderr: ERROR: Permission to project/repo.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

还尝试通过将 Jenkins 服务器的存储库特定路径存储在 GHE 中来Webhooks,但没有发现任何更改:

https://<jenkins_server>:8080/job/<repo_name>/

建议/帮助将不胜感激。谢谢!

看起来您正在使用多个键。 除非另有说明,否则 SSH 将加载默认密钥。

创建 SSH 配置文件

当您有多个身份文件时,请创建 SSH 配置文件机制,以便为各种身份创建别名。

您可以使用许多参数和不同的方法构造 SSH 配置文件。

此示例中使用的别名条目的格式为:

Host alias 
HostName <domain.com>
IdentityFile ~/.ssh/identity

要为两个标识(工作 ID 和个人 ID)创建配置文件,请执行以下操作:

Open a terminal window.
Edit the ~/.ssh/config file. 

如果没有配置文件,请创建一个。
为每个身份组合添加别名,例如:

Host host1
HostName <domain1>
IdentityFile ~/.ssh/key1
Host host2
HostName <domain2>
IdentityFile ~/.ssh/key2

在您的情况下,域应该是相同的,并添加您的 2 个键:id_rsaid_ecdsa

编辑 ssh 配置:

nano ~/.ssh/config

仅设置标识=否

Host *
IdentitiesOnly=no

(感谢代码向导)

最新更新