【问题标题】:Trouble with connecting to Git Server via Jenkins通过 Jenkins 连接到 Git 服务器的问题
【发布时间】:2016-05-13 16:49:07
【问题描述】:

朋友们,我在 Jenkins 控制台中不断收到以下错误。

"Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://yyyyyyyy@gerrit.xxxxxxxx.com:29418/mobile 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."

尝试了网络上的所有选项。没有任何效果。 在这里感谢您的帮助

在此处填写日志

Building in workspace /Users/Shared/Jenkins/GIT
Cloning the remote Git repository
Cloning repository ssh://yyyyy@gerrit.xxxxxxxx.com:29418/mobile
 > git init /Users/Shared/Jenkins/GIT # timeout=10
Fetching upstream changes from ssh://yyyyy@gerrit.xxxxxxxx.com:29418/mobile
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress ssh://yyyyyyy@gerrit.xxxxxxxxx.com:29418/mobile +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress ssh://yyyyyy@gerrit.xxxxxxxxx.com:29418/mobile +refs/heads/*:refs/remotes/origin/*" 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 文件夹,并且能够通过命令提示符(终端)连接到 GIT。我使用 OS X 顺便说一句
  • 您是否可以在没有 jenkins 的情况下使用 ssh 在本地系统上克隆 repo?
  • 当然。确实如此。但有时我确实必须运行此命令 /n ssh-add .ssh/id_rsa /n 才能使克隆命令起作用 只有通过 Jenkins 的问题

标签: git jenkins ssh git-clone


【解决方案1】:

我认为这是您的 .ssh 文件夹或 id_rsa* 文件的权限问题。

请查看这篇文章以设置正确的权限: https://superuser.com/questions/215504/permissions-on-private-key-in-ssh-folder

.ssh 文件夹应该存在于您的 jenkins 用户的主文件夹中(类似于 /home/jenkins 或 /var/lib/jenkins)。

权限应该是:

  • .ssh 文件夹:700 (drwx------)
  • 公钥(.pub):644(-rw-r--r--)
  • 私钥(id_rsa):600(-rw-------)

请确认它解决了您的问题:)

【讨论】:

  • 谢谢布鲁诺。但是权限设置为 777 就像完全访问一样。还是同样的问题 Madhav-iMAC:Madhav administrator$ ls -l .ssh/ total 16 -rwxrwxrwx 1 jenkins staff 3326 May 12 18:44 id_rsa -rwxrwxrwx 1 jenkins staff 763 May 12 18:44 id_rsa.pub
  • 另外,Jenkins怎么知道.ssh文件夹的位置?
  • 我已经更新了我的答案。您必须使用 .ssh 文件夹和 id_rsa* 文件的确切权限。否则,您的密钥将不会被识别。
  • 我进行了更改。仍然是同样的问题。会继续努力。谢谢
  • 你的 git 仓库管理器是什么?集线器?还是像 Atlassian Bitbucket 这样的托管解决方案?
猜你喜欢
  • 2023-03-06
  • 2020-09-19
  • 1970-01-01
  • 2017-03-01
  • 2011-11-16
  • 1970-01-01
  • 2018-12-20
  • 2020-05-25
  • 2017-07-05
相关资源
最近更新 更多