我可以在托管Jenkins应用程序的Linux服务器上克隆我的git存储库,但是当我尝试创建一个新的Jenkins作业时,我收到错误128。
“无法连接到存储库:命令”git ls-remote -h ssh://git@bitbucket.org/user/proj.git HEAD“返回状态码128:stdout:stderr:权限被拒绝(公钥)。致命:可能不从远程存储库读取。
请确保您拥有正确的访问权限并且存储库已存在。“
我做的事情
关于终端的工作
bash-4.2$
bash-4.2$ whoami
jenkins
bash-4.2$ ssh -T git@bitbucket.org
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://git@bitbucket.org/user/proj.git
[ec2-user@ip-172-31-31-13 ~]$ git -c core.askpass=true ls-remote -h ssh://git@bitbucket.org/user/proj.git
db710fbf01f08789cf5c15e66269013f8e1543d4 refs/heads/master
图片:
2-ssh 2 git using default user
在Jenkins中配置它时,我会尝试编写git存储库的URL,如git@[...]
而不是ssh://git@[...]
另一方面,您作为test3
(ssh-rsa AAA[...]
)的私钥引入的密钥似乎不是私钥。它看起来像公钥。私钥是一个以-----BEGIN RSA PRIVATE KEY-----
开头并以-----END RSA PRIVATE KEY-----
结尾的块。在你的情况下,我认为它存储在名为jenkins_bitbucket_access
的文件中(公钥存储在jenkins_bitbucket_access.pub
中)
问题解决了!当我在Jenkins Web上创建SSH凭据时,我使用了我的公钥而不是私钥...现在一切正常:)