尝试让詹金斯和 gitolite 成功工作 - 权限被拒绝(公钥、密码)

发布于 2024-12-07 00:25:28 字数 4742 浏览 0 评论 0原文

几天来我一直在尝试让我的 gitolite 与 jenkins 一起工作,这样我就可以从服务器托管存储库并与 Jenkins 一起工作(它们位于同一服务器上)。

我有 gitolite 工作,但我想我在 ssh 方面有问题。 我在聊天中获得了一些帮助,并将私钥添加到 jenkins/.ssh 中。

我有一个托管 gitolite 的用户“git”,并且有一个用户“gitolite”和一个“jenkins”用户。我可以使用 git clone [email protected]:Matrix

But 克隆存储库我不能在詹金斯中使用它。当我尝试构建时我得到了这个。

Checkout:workspace / /var/lib/jenkins/jobs/Matrix/workspace -
hudson.remoting.LocalChannel@dbb335
Using strategy: Default
Checkout:workspace / /var/lib/jenkins/jobs/Matrix/workspace -
hudson.remoting.LocalChannel@dbb335

Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:Matrix
ERROR: Cause: Error performing command: git clone --progress -o origin [email protected]:Matrix /var/lib/jenkins/jobs/Matrix/workspace
Command "git clone --progress -o origin [email protected]:Matrix
/var/lib/jenkins/jobs/Matrix/workspace" returned status code 128: Cloning into        /var/lib/jenkins/jobs/Matrix/workspace...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly

Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1042)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:758)
at hudson.FilePath.act(FilePath.java:740)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:566)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:454)
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:230)

我登录到我的服务器和 su - jenkins,然后输入“ssh -v git@server”我得到了这个。

git@Server:~$ sudo su - jenkins
jenkins@Server:~$ ssh -v git@server
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to server [127.0.1.1] port 22.
debug1: Connection established.
debug1: identity file /var/lib/jenkins/.ssh/id_rsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_rsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-1ubuntu3
debug1: match: OpenSSH_5.8p1 Debian-1ubuntu3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA f3:ab:a6:55:83:98:c5:4f:85:c6:70:be:2f:40:1f:65
debug1: Host 'server' is known and matches the ECDSA host key.
debug1: Found key in /var/lib/jenkins/.ssh/known_hosts:3
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /var/lib/jenkins/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /var/lib/jenkins/.ssh/id_dsa
debug1: Trying private key: /var/lib/jenkins/.ssh/id_ecdsa
debug1: Next authentication method: password
git@server's password: 

仍然要求输入密码... 有谁做过这样的事吗?让 gitolite 与詹金斯一起工作? 我非常感谢您的帮助,并且很乐意捐赠 10 美元(签证卡)来帮助我进行设置!

I have been trying for days to get my gitolite work with jenkins so I can have repos hosted from server and working with Jenkins (they are on the same sever).

I have gitolite working but I guess I have problems with ssh.
I got some help on a chat and added private key to jenkins/.ssh.

I have a user "git" that hosts the gitolite, and I got a user "gitolite" and a "jenkins" user. I can clone a repo by using git clone [email protected]:Matrix

But I can't use it in jenkins. I get this when I try to build.

Checkout:workspace / /var/lib/jenkins/jobs/Matrix/workspace -
hudson.remoting.LocalChannel@dbb335
Using strategy: Default
Checkout:workspace / /var/lib/jenkins/jobs/Matrix/workspace -
hudson.remoting.LocalChannel@dbb335

Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:Matrix
ERROR: Cause: Error performing command: git clone --progress -o origin [email protected]:Matrix /var/lib/jenkins/jobs/Matrix/workspace
Command "git clone --progress -o origin [email protected]:Matrix
/var/lib/jenkins/jobs/Matrix/workspace" returned status code 128: Cloning into        /var/lib/jenkins/jobs/Matrix/workspace...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly

Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1042)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:758)
at hudson.FilePath.act(FilePath.java:740)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:566)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:454)
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:230)

I login to my server and su - jenkins, then type "ssh -v git@server" I get this.

git@Server:~$ sudo su - jenkins
jenkins@Server:~$ ssh -v git@server
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to server [127.0.1.1] port 22.
debug1: Connection established.
debug1: identity file /var/lib/jenkins/.ssh/id_rsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_rsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-1ubuntu3
debug1: match: OpenSSH_5.8p1 Debian-1ubuntu3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA f3:ab:a6:55:83:98:c5:4f:85:c6:70:be:2f:40:1f:65
debug1: Host 'server' is known and matches the ECDSA host key.
debug1: Found key in /var/lib/jenkins/.ssh/known_hosts:3
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /var/lib/jenkins/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /var/lib/jenkins/.ssh/id_dsa
debug1: Trying private key: /var/lib/jenkins/.ssh/id_ecdsa
debug1: Next authentication method: password
git@server's password: 

It still asks for password...
Anyone who have done this? Getting gitolite working with jenkins?
I'm very grateful for any help and can gladly donate 10 bucks (visa card) for helping me set this up!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤千羽 2024-12-14 00:25:28

通过 SSH 进入 Jenkins 盒子,并为 Jenkins 用户创建 SSH 密钥对(此处假设为 jenkins):

local$ ssh jenkins-box
you@jenkins-box$ sudo su jenkins
jenkins@jenkins-box$ ssh-keygen
jenkins@jenkins-box$ cat $HOME/.ssh/id_rsa.pub

复制您在屏幕上看到的 SSH 公钥并将其粘贴到新文件 keydir/ 中jenkins.pub 位于本地 gitolite 管理存储库中。

将以下行添加到 conf/gitolite.conf 中,以授予 Jenkins 克隆和拉取所有存储库的权限:

repo    @all
        R       =   jenkins

提交并推送 gitolite 管理存储库。詹金斯现在应该可以正常工作了。

SSH into the Jenkins box and create an SSH key pair for the Jenkins user (assuming jenkins here):

local$ ssh jenkins-box
you@jenkins-box$ sudo su jenkins
jenkins@jenkins-box$ ssh-keygen
jenkins@jenkins-box$ cat $HOME/.ssh/id_rsa.pub

Copy the SSH public key you see on the screen and paste it into the new file keydir/jenkins.pub inside your local gitolite admin repository.

Add the following lines to conf/gitolite.conf to give Jenkins permissions to clone and pull all repositories:

repo    @all
        R       =   jenkins

Commit and push the gitolite admin repository. Jenkins should now work correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文