设置 Jenkins 时权限被拒绝(公钥) [英] Permission denied (publickey) when setting up Jenkins

查看:42
本文介绍了设置 Jenkins 时权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Win 2008 服务器机器上设置 Jenkins,但在配置 Jenkins 以连接到 GitHub 时遇到了一些问题.我收到以下错误:

命令git.exe fetch -t git@github.com:USER/REPO.git +refs/heads/*:refs/remotes/origin/*"返回状态码128:权限被拒绝(公钥).致命:远端意外挂断错误:无法从任何存储库中获取致命:无法从任何存储库中获取hudson.plugins.git.GitException:无法从任何存储库中获取在 hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:950)在 hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:908)在 hudson.FilePath.act(FilePath.java:758)在 hudson.FilePath.act(FilePath.java:740)在 hudson.plugins.git.GitSCM.checkout(GitSCM.java:908)在 hudson.model.AbstractProject.checkout(AbstractProject.java:1184)在 hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:537)在 hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:425)在 hudson.model.Run.run(Run.java:1376)在 hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)在 hudson.model.ResourceController.execute(ResourceController.java:88)在 hudson.model.Executor.run(Executor.java:175)

我检查过的东西

  • Jenkins 服务正在使用我的用户名运行.
  • 我更改了我的 SSH 密钥,所以它不再有密码.
  • 我已通过使用 msysgit 执行与 Jenkins 相同的命令来验证我的 SSH 密钥是否有效.
  • 验证我所有的路径都正确.

Jenkins 配置设置

  • 詹金斯 1.418
  • GitHub 插件 0.5
  • Git 插件 1.1.9

msysgit 有效但 CMD 提示无效当我导航到一个有效的存储库并从 DOS 提示符执行命令时,它也失败了.

你知道我可能遗漏了什么吗?

感谢您的帮助.

解决方案

正如我所评论的,在使用 ssh 协议时,指定 HOME 环境变量是关键.
由于 Windows 没有 HOME,您需要将其明确定义到您想要的任何目录.

但是,"中所述)莉>

如果你有一个参数化的构建,你也可以可以定义HOME 那样 并检查您的奴隶是否为 HOME 选择了正确的值:

I am setting up Jenkins on a Win 2008 server machine and am having some trouble configuring Jenkins to connect to GitHub. I get the following error:

Command "git.exe fetch -t git@github.com:USER/REPO.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:950)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:908)
    at hudson.FilePath.act(FilePath.java:758)
    at hudson.FilePath.act(FilePath.java:740)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:908)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1184)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:537)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:425)
    at hudson.model.Run.run(Run.java:1376)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:175)

Things I Have Checked

  • The Jenkins service is running under my username.
  • I changed my SSH key so it no longer has a password.
  • I have verified my SSH key is valid by executing the same command as Jenkins using msysgit.
  • Verified all my paths are correct.

Jenkins Configuration Settings

  • Jenkins 1.418
  • GitHub plugin 0.5
  • Git plugin 1.1.9

msysgit Works but CMD Prompt Does Not When I navigate to a valid repo and execute the command from the DOS prompt, it also fails.

Do you have any idea what I may be missing?

Thanks for your help.

解决方案

As I commented, specifying the HOME environment variable is key, when using ssh protocol.
Since Windows doesn't have a HOME, you need to define it explicitly, to whatever directory you want.

However, Vestnik comments:

I've specified to override HOME on the windows slave node to point it to C:jenkins.
I've put correct id_rsa under the C:jenkins.ssh but still have this issue.
My slave agent running as service under SYSTEM account.

Two advices:

  • you need to make your slave display 'set' in order to check if HOME is defined when used with the SYSTEM account.
    If it is not, that may mean you need to add that variable to the "system environment variables", not the "user environment variables".

  • Don't forget to have both id_rsa and id_rsa.pub in the %HOME%.ssh directory: you need both public and private ssh keys. (as mentioned in "git clone with ssh issue")

If you have a parametrized build, you also can define HOME that way and check if your slave picks up the right value for HOME:

这篇关于设置 Jenkins 时权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆