git jenkins/hudson 无法连接到 github 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10224574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jenkins/hudson can't connect to github repo
提问by Chris Mccabe
I am on Ec2 with the base amazon ami linux- I have installed jenkins but when I go to pull the repo from github I am given the following error:
我在 Ec2 上使用基本的 amazon ami linux-我已经安装了 jenkins,但是当我从 github 中提取 repo 时,出现以下错误:
Building in workspace /var/lib/jenkins/workspace/build social
Checkout:build social / /var/lib/jenkins/workspace/build social - hudson.remoting.LocalChannel@5c7b21b
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:adulion/.git
hudson.plugins.git.GitException: Could not clone [email protected]:adulion/.git
at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
at hudson.plugins.git.GitSCM.invoke(GitSCM.java:1117)
at hudson.plugins.git.GitSCM.invoke(GitSCM.java:1059)
at hudson.FilePath.act(FilePath.java:832)
at hudson.FilePath.act(FilePath.java:814)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1059)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1218)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:581)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:470)
at hudson.model.Run.run(Run.java:1421)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin [email protected]:adulion/.git /var/lib/jenkins/workspace/build social" returned status code 128:
stdout: Cloning into /var/lib/jenkins/workspace/build social...
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly
I have generated a key for the current user who installed jenkins and have managed to clone the repo using the git command line but jenkins can not.
我已经为安装 jenkins 的当前用户生成了一个密钥,并设法使用 git 命令行克隆了 repo,但 jenkins 不能。
I have copied the ~/.ssh files into /var/lib/jenkins/.ssh
我已将 ~/.ssh 文件复制到 /var/lib/jenkins/.ssh
I have added github to the known hosts and I have run out of solutions to try. Anyone know where I am going wrong? Is there a way to get jenkins to show the public key it's using and I can debug if it's using the correct one?
我已将 github 添加到已知主机,但我已用尽解决方案。有谁知道我哪里出错了?有没有办法让 jenkins 显示它正在使用的公钥,我可以调试它是否使用正确的公钥?
I removed the name of the repo because its a private repo
我删除了 repo 的名称,因为它是一个私有 repo
回答by sti
The error seems to be: host key verification failed.
错误似乎是:主机密钥验证失败。
You should log into your Jenkins host as the Jenkins user and run:
您应该以 Jenkins 用户身份登录到您的 Jenkins 主机并运行:
ssh [email protected]
Then answer yes to the prompt about the host key. This only needs to be done once.
然后对有关主机密钥的提示回答是。这只需要做一次。
Alternatively you could add "StrictHostKeyChecking no" to ~jenkins/.ssh/config.
或者,您可以将“StrictHostKeyChecking no”添加到 ~jenkins/.ssh/config。
回答by mpdaugherty
I'm using a single jenkins machine to check out multiple github repositories and had similar problems when setting it up. What I ended up doing was configuring an SSH config file for jenkins so that SSH would automatically know which id file to associate with each repository.
我正在使用一台 jenkins 机器来检查多个 github 存储库,并且在设置时遇到了类似的问题。我最终做的是为 jenkins 配置一个 SSH 配置文件,以便 SSH 自动知道哪个 id 文件与每个存储库相关联。
/var/lib/jenkins/.ssh/config:
/var/lib/jenkins/.ssh/config:
Host github-ABC
HostName github.com
User git
IdentityFile /var/lib/jenkins/.ssh/id_rsa_ABC
In the Jenkins project config under source code management, I used this as the repository name:
在源代码管理下的Jenkins项目配置中,我使用这个作为存储库名称:
git@github-ABC:user/repo.git
Finally, I use the SSH public key as a deploy key in the github repository.
最后,我使用 SSH 公钥作为 github 存储库中的部署密钥。
回答by Max
He following helped me:
他以下帮助了我:
Login under Jenkins
在Jenkins下登录
sudo su jenkins
Copy your github key to Jenkins .ssh folder
将您的 github 密钥复制到 Jenkins .ssh 文件夹
cp ~/.ssh/id_rsa_github* /var/lib/jenkins/.ssh/
Raname the keys
给钥匙命名
mv id_rsa_github id_rsa
mv id_rsa_github.pub id_rsa.pub
回答by greg
1) Switch User into your jenkins account
1) 将用户切换到您的 jenkins 帐户
su jenkins
2) Create the key without a passphrase
2)创建没有密码的密钥
3) ssh [email protected]
3) ssh [email protected]
That worked perfectly for me.
这对我来说非常有效。
You may need to create a password for the jenkins account, if so use sudo passwd jenkins
您可能需要为 jenkins 帐户创建密码,如果是这样,请使用 sudo passwd jenkins
回答by user1786927
If you log in as jenkins you can do
如果您以 jenkins 身份登录,则可以执行以下操作
ssh -i ~/.ssh/id_rsa [email protected]
ssh -i ~/.ssh/id_rsa [email protected]
where ~/.ssh/id_rsa is the path/to/your/ssh/key and it will prompt for the password and add to the known_hosts file
其中 ~/.ssh/id_rsa 是 path/to/your/ssh/key 它将提示输入密码并添加到 known_hosts 文件
回答by surfer190
You need to add the ssh key of jenkins to you github user.
您需要将 jenkins 的 ssh 密钥添加到您的 github 用户。
Go to:
去:
Github->Settings(Top right)->SSH Keys(Left Pane)->Add SSH Key
Github->Settings(Top right)->SSH Keys(Left Pane)->Add SSH Key