【发布时间】:2016-12-26 16:00:46
【问题描述】:
我正在尝试在本地机器上设置新的 jenkins 项目,我在 Source Code Management 部分的 Git Repositories 下添加了 bitbucket 存储库
但我得到一个错误:
Failed to connect to repository : Command "git ls-remote -h ssh://git@<main_link>/<name1>/<name2>.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
但是我可以从我的控制台运行此命令(我也可以执行git clone 等)
我尝试通过Add Credentials 使用选项Private Key - Enter directly 添加ssh 密钥
据我所知,我的私钥在~/.ssh/
ls ~/.ssh/
cat ~/.ssh/id_dsa
但在我从~/.ssh/id_dsa 输入私人 ssh 密钥后,没有任何改变,我仍然收到错误。
更新: 试过这个答案:https://stackoverflow.com/a/15314910/1179925
sudo -i -u jenkins
jenkins@user-VirtualBox:~$ git clone ssh://git@<link>/<name1>/<name2>.git
Cloning into '<name2>'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
【问题讨论】:
-
你看过这篇文章了吗:stackoverflow.com/questions/15314760/…
-
这是预期的:您正在使用 Jenkins 帐户,而您的密钥在您的帐户中。
-
@VonC 是的,你是对的。