Jenkins - SSH存储库URL无法连接

时间:2015-02-19 09:52:26

标签: git ssh jenkins

我在CentOS中安装了Jenkins,并且还安装了git插件以便使用Bitbucket。在源代码管理中添加存储库URL时,HTTPS工作正常,但是当我添加SSH网址时,弹出以下错误 -

Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h git@bitbucket.org:ash_dy/test_1.git HEAD" returned status code 128:
stdout: 
stderr: Host key verification failed. 
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我已经搜索了这个,但没有找到我的问题的任何答案,我想使用ssh而不是Https所以请帮助。

2 个答案:

答案 0 :(得分:0)

尝试在您的计算机上以jenkins用户身份登录。然后执行:

ssh -T git@bitbucket.org

此命令将验证您和bitbucket之间的ssh配置。也许你的ssh密钥不是好的。

答案 1 :(得分:0)

我终于找到了解决问题的方法,我将其发布给其他人。

  1. 通过修改/etc/passwd /并将/bin/false更改为/bin/bash来为jenkins用户配置shell。

  2. su - jenkins。请注意,jenkins用户的主页是/var/lib/jenkins

  3. ssh-keygen然后cat .ssh/id_rsa.pub并将此密钥复制到您的bitbucket帐户

  4. ssh git@bitbucket.org在.ssh / known_hosts中设置bitbucket ssh密钥

  5. 现在你应该可以从Jenkins访问bitbucket了。

    参考link