Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向Jenkins添加GitHub私人回购_Git_Jenkins_Github_Repository - Fatal编程技术网

向Jenkins添加GitHub私人回购

向Jenkins添加GitHub私人回购,git,jenkins,github,repository,Git,Jenkins,Github,Repository,我正试图将我的私人GitHub回购协议添加到Jenkins的工作中 我选择了源代码管理“Git”,将ssh链接放到我的GitHub并选择了我的凭据,但它仍然给我这个错误 Failed to connect to repository : Command "git ls-remote -h -- git@github.com:DanSmith/MyPrivateRepo.git HEAD" returned status code 128: stdout: stderr: Warning: Per

我正试图将我的私人GitHub回购协议添加到Jenkins的工作中

我选择了源代码管理“Git”,将ssh链接放到我的GitHub并选择了我的凭据,但它仍然给我这个错误

Failed to connect to repository : Command "git ls-remote -h -- git@github.com:DanSmith/MyPrivateRepo.git HEAD" returned status code 128:
stdout:
stderr: Warning: Permanently added the RSA host key for IP address '140.**.***.*' to the list of known hosts.
Load key "/tmp/ssh87617326.key": invalid format
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
您可以从中跟随“”

这些步骤包括:

  • 创建专用SSH密钥

    ssh-keygen -m PEM -t rsa -P "" -C "jenkins.me" -f jenkinskey
    
这将创建一个没有密码短语的jenkinskey/jenkinskey.pub(因为Jenkins在运行时无法输入密码)。
其格式(对于私钥)应为:64个字符宽,注76

  • 登记
  • 在Jenkins中将您的私钥注册为凭据(假设您已安装此证书)
    确保复制
    ----开始RSA私钥------
    ----结束RSA私钥------
    ,而不丢失'-'(as)

  • 确保Jenkins知道github.com

    ssh -T git@github.com
    
即使~jenkins/.ssh没有密钥,也会将github.com添加到~jenkins/.ssh/known_主机中

  • 最后,将之前输入的凭据名称用于Jenkins作业的Git配置:

我已经做了所有这些,但在添加回购url并设置credentials@Dan是否执行ssh-Tv-i/path/to/private/keygit@github.com起作用了?是的,它说成功了authenticated@Dan不,它不能“轻易被入侵”:这就是为什么您只为Jenkins创建一个专用SSH密钥,要在GitHub帐户中注册,请与通常的SSH密钥(可能有密码短语)分开:如果您有任何疑问,可以撤销该密钥并重新生成另一个。@Dan但是,请再次尝试并遵循我的答案:它应该可以工作。