向Jenkins添加GitHub私人回购
我正试图将我的私人GitHub回购协议添加到Jenkins的工作中 我选择了源代码管理“Git”,将ssh链接放到我的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
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
其格式(对于私钥)应为:64个字符宽,注76
- 登记
- 在Jenkins中将您的私钥注册为凭据(假设您已安装此证书)
确保复制
到----开始RSA私钥------
,而不丢失'-'(as)----结束RSA私钥------
- 确保Jenkins知道github.com
ssh -T git@github.com
- 最后,将之前输入的凭据名称用于Jenkins作业的Git配置:
我已经做了所有这些,但在添加回购url并设置credentials@Dan是否执行ssh-Tv-i/path/to/private/keygit@github.com起作用了?是的,它说成功了authenticated@Dan不,它不能“轻易被入侵”:这就是为什么您只为Jenkins创建一个专用SSH密钥,要在GitHub帐户中注册,请与通常的SSH密钥(可能有密码短语)分开:如果您有任何疑问,可以撤销该密钥并重新生成另一个。@Dan但是,请再次尝试并遵循我的答案:它应该可以工作。