尝试使用jenkins克隆git存储库时出错128

问题描述 投票:-1回答:2

我可以在托管Jenkins应用程序的Linux服务器上克隆我的git存储库,但是当我尝试创建一个新的Jenkins作业时,我收到错误128。

“无法连接到存储库:命令”git ls-remote -h ssh://[email protected]/user/proj.git HEAD“返回状态码128:stdout:stderr:权限被拒绝(公钥)。致命:可能不从远程存储库读取。

请确保您拥有正确的访问权限并且存储库已存在。“

我做的事情

  1. 在Linux服务器上安装git。
  2. 安装BitBucket插件,它依赖于Jenkins应用程序。
  3. 创建SSH密钥。
  4. 将密钥导入BitBucket和Jenkins文件夹。
  5. 在SSH密钥上为Jenkins用户设置权限。
  6. 我在Jenkins应用程序上创建了SSH凭据。

关于终端的工作

bash-4.2$ bash-4.2$ whoami jenkins bash-4.2$ ssh -T [email protected] authenticated via a deploy key. You can use git or hg to connect to Bitbucket. Shell access is disabled. This deploy key has read access to the following repositories: user/proj: test3 -- jenkins@git 。 。

git -c core.askpass=true ls-remote -h ssh://[email protected]/user/proj.git [ec2-user@ip-172-31-31-13 ~]$ git -c core.askpass=true ls-remote -h ssh://[email protected]/user/proj.git db710fbf01f08789cf5c15e66269013f8e1543d4 refs/heads/master

图片:

1-linux jenkins ver

2-ssh 2 git using default user

3-ssh 2 git using jenkins user

4-ssh rsa keys

5-jenkins auth keys

6-jenkins cred

7-jenkins web error

git jenkins bitbucket permission-denied public-key
2个回答
0
投票

在Jenkins中配置它时,我会尝试编写git存储库的URL,如git@[...]而不是ssh://git@[...]

另一方面,您作为test3ssh-rsa AAA[...])的私钥引入的密钥似乎不是私钥。它看起来像公钥。私钥是一个以-----BEGIN RSA PRIVATE KEY-----开头并以-----END RSA PRIVATE KEY-----结尾的块。在你的情况下,我认为它存储在名为jenkins_bitbucket_access的文件中(公钥存储在jenkins_bitbucket_access.pub中)


0
投票

问题解决了!当我在Jenkins Web上创建SSH凭据时,我使用了我的公钥而不是私钥...现在一切正常:)

© www.soinside.com 2019 - 2024. All rights reserved.