在centos上设置jenkins:ssh keys和git的问题 [英] Setting up jenkins on centos: problems with ssh keys and git

查看:373
本文介绍了在centos上设置jenkins:ssh keys和git的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经历了很多问题,但似乎没有解决我的问题。或者更准确地说,我不知道我是否正确地做了所有的事情。
所以这里是:



已经安装了centos 6.3操作系统。
然后我按照以下指南安装jenkins:



https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions



Jenkins工作正常。现在我想设置一个简单的构建作业,这需要克隆一个git存储库。 (我已经安装了git插件)



在存储库URL我键入以下:
git @ gitserver:myrepo.git
当然,错误:stderr:主机密钥验证失败。



确定,我需要生成ssh密钥,一切都会很好。
所以我这样做:

  su  -  jenkins 
pre>

但不幸的是它不会切换到jenkins用户。



cat / etc / passwd



显示以下内容:

  jenkins:x:496:492:Jenkins Continuous构建服务器:/ var / lib / jenkins:/ bin / false 

有一个通常的主目录。



问题是如何为jenkins生成密钥或如果上述步骤没有正确的方法,如何解决它



非常感谢!



更新
键(作为root用户),并将它们放在jenkins home中,并完全复制公钥到git服务器。仍然没有帮助。



当我看到构建的日志时,它说:

 由用户启动anonymous 
构建在工作区/ var / lib / jenkins / jobs / myrepo / workspace

此用户anonymous是jenkins创建的另一个用户,还是仍然是运行命令的jenkins?

解决方案

我假设你有root权限,如果你能够安装Jenkins RPM。你以root身份登录时是否接受jenkins用户?如果没有,您应该这样做或使用

  sudo su  -  jenkins 

然后运行

  ssh-keygen -t rsa 

为jenkins用户生成RSA密钥对,您可以将公钥上传到您的git服务器。如果采用默认值,键将生成为/var/lib/jenkins/.ssh.id_ra.pub。


Went through a lot of questions, but nothing seems to be solving my issue. Or to be more precise I am not sure if I am doing the whole thing correctly. So here it is:

Have installed centos 6.3 OS. Then I followed the following guide to install jenkins:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions

Jenkins works fine. Now I am trying to set up a simple build job, which requires to clone a git repository. (I've installed git plugin)

In repository URL i type the following: git@gitserver:myrepo.git Of course I get an error: stderr: Host key verification failed.

ok, I need to generate ssh keys and all will be good. So I do the following:

su - jenkins

but unfortunately it doesn't switch to jenkins user.

cat /etc/passwd

shows the following:

jenkins:x:496:492:Jenkins Continuous Build Server:/var/lib/jenkins:/bin/false

so seems that it doesn't have a usual home directory.

The question is how do I generate keys for jenkins or if the above steps where not the right way to do it, how do I fix it?

Thanks a lot!

Update: I generated keys (as a root user) and placed them in jenkins home and did exactly and copied public key to git server. Still didn't help.

When I look at the log of the build it says:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/myrepo/workspace

this user anonymous is this another user created by jenkins, or is it still jenkins that runs the commands?

解决方案

I'm assuming that you have root access if you were able to install the Jenkins RPM. Were you su-ing to the jenkins user while logged in as root ? If not, you should do so or use

sudo su - jenkins

if your logged in user has sudo access.

Then run

ssh-keygen -t rsa

to generate an RSA keypair for the jenkins user, and you can upload the public key to your git server. The key will be generated as /var/lib/jenkins/.ssh.id_ra.pub if you take the defaults.

这篇关于在centos上设置jenkins:ssh keys和git的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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