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

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

问题描述

问了很多问题,但似乎没有什么能解决我的问题.或者更准确地说,我不确定我是否正确地完成了整件事.所以这里是:

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:

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

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

https://wiki.jenkins-ci.org/display/JENKINS/安装+Jenkins+on+RedHat+发行版

詹金斯工作正常.现在我正在尝试设置一个简单的构建作业,它需要克隆一个 git 存储库.(我已经安装了 git 插件)

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)

在存储库 URL 中,我键入以下内容:git@gitserver:myrepo.git当然我得到一个错误:stderr:主机密钥验证失败.

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

好的,我需要生成 ssh 密钥,一切都会好的.所以我做了以下事情:

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

su - jenkins

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

but unfortunately it doesn't switch to jenkins user.

cat/etc/passwd

cat /etc/passwd

显示以下内容:

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

看来它没有通常的主目录.

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

问题是我如何为 jenkins 生成密钥,或者如果上述步骤不是正确的方法,我该如何解决?

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?

非常感谢!

更新:我生成了密钥(作为 root 用户)并将它们放在 jenkins 家中,并准确地完成并将公钥复制到 git 服务器.仍然没有帮助.

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

这个匿名用户是 jenkins 创建的另一个用户,还是 jenkins 运行命令?

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

推荐答案

如果您能够安装 Jenkins RPM,我假设您具有 root 访问权限.以 root 身份登录时,您是否向 jenkins 用户发起了诉讼?如果没有,您应该这样做或使用

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

如果您的登录用户具有 sudo 访问权限.

if your logged in user has sudo access.

然后运行

ssh-keygen -t rsa

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

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 密钥和 git 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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