对Github的SSH访问:shell没关系,Jenkins失败了

bis*_*ish 1 authentication github jenkins

在您立即将其标记为可能重复之前,请阅读整篇文章

TLDR:我正在尝试建立一个jenkins来读取私有 Github存储库.当我使用jenkins凭证时username/password,如果我使用jenkins凭证,private key它不会,并且我收到"无效的用户名/密码"错误.

详细描述:

  1. 我在apache-tomcat 8上安装了jenkins 2.5,jenkins在用户下运行tomcat8.还安装了凭据插件(2.1.4),Git客户端插件(1.19.6),Gitplugin(2.5.2),Github API插件(1.76),GitHub插件(1.19.2),SSH凭证插件(1.12).Git在2.1.4版本中运行
  2. 我为用户tomcat8 创建了一个带空密码的ssh- keypair [以tomcat8身份登录sudo -su tomcat8]
  3. 我已将公钥添加到私有Github存储库
  4. 我创建了一个詹金斯凭证ssh username with private key与全球范围内,用户名tomcat8,密码为空和满的私钥-----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----
  5. 我使用github帐户的普通用户名和密码创建了一个jenkins信用卡"用户名/密码".
  6. 当我登录用户tomcat8并使用命令通过shell检查github身份验证时,ssh -T git@github.com我得到了正确的输出.这意味着我使用密钥对github的身份验证工作(对吧?)

    tomcat8 @ ci:〜/ .ssh $ ssh -T git@github.com你好github-username!您已成功通过身份验证,但GitHub不提供shell访问权限.

Wenn我现在设置我的jenkins工作:repository URL: https://github.com/repoownername/reponame.git并使用username/passwort-credential访问很好.但是当我使用ssh-credentials时,身份验证就会失败

无法连接到存储库:命令"git -c core.askpass = true ls-remote -h https://github.com/repoownername/reponame.git HEAD"返回状态码128:stdout:stderr:remote:用户名无效或密码.致命:" https://github.com/repoownername/reponame.git "的身份验证失败

更多信息当我使用用户名/密码凭据运行构建时

git config remote.origin1.url https://github.com/repoownername/reponame.git#timeout = 10 使用.gitcredentials 从https://github.com/repoownername/reponame.git获取上游更改以设置凭据git config - -local credential.username github-username #timeout = 10 git config --local credential.helper store --file =/tmp/tomcat8-tomcat8-tmp/git1018128562913260002.credentials #timeout = 10 git -c core.askpass = true fetch --tags --progress https://github.com/repoownername/reponame.git + refs/heads/:refs/remotes/origin1 / git config --local --remove-section credential #timetime = 10

当我使用SSH凭据时,我得到上面提到的错误.

所以现在我的问题是:如何成功使用我的SSH凭证而不是用户名/密码

我检查过的一些教程:

bis*_*ish 9

噢,我有点傻了.

我的错误是我使用了我的存储库的错误URL!我用过:

https://github.com/repoownername/reponame.git使用username/password凭据时工作正常.

但对于SSH-Acess我必须使用

git@github.com:repoownername/reponame.git