【问题标题】:Jenkins - SSH Repository URL unable to connectJenkins - SSH 存储库 URL 无法连接
【发布时间】:2015-04-20 14:40:55
【问题描述】:

我已经在 CentOS 中安装了 Jenkins,还安装了 git 插件以便使用 Bitbucket。在源代码管理中添加存储库 URL 时,HTTPS 效果很好,但是当我添加 SSH url 时会弹出以下错误 -

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,所以请帮忙。

【问题讨论】:

  • git 用户是否通过密钥或您输入密码进行无密码访问?

标签: git ssh jenkins


【解决方案1】:

我终于找到了我的问题的解决方案,我在这里发布给其他人。

  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 密钥

现在您应该可以从 Jenkins 访问 bitbucket。

参考link

【讨论】:

    【解决方案2】:

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

    ssh -T git@bitbucket.org
    

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

    【讨论】:

    • 我使用的是 windows,它没有 jenkins 用户,这是正确的还是我错过了什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-09
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 2018-01-04
    相关资源
    最近更新 更多