在使用Ubuntu上的Jenkins用户从GitHub获取权限时,权限被拒绝(公钥) [英] Permission denied (public key) during fetch from GitHub with Jenkins user on Ubuntu

查看:163
本文介绍了在使用Ubuntu上的Jenkins用户从GitHub获取权限时,权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的设置:


  1. Jenkins在我的linux机器上以'jenkins'用户身份运行。

  2. 我已经生成了一个ssh密钥对,如 Linux - Setup Git <当我 sudo su jenkins 并且尝试 ssh - 时, vT git@github.com ,我总是被问到我的密码,但我总是最终被授权。 (详细选项显示使用哪个密钥等)。
  3. 我可以使用jenkins从GitHub克隆我的回购:

因此:

  jenkins @ alpm:〜/ jobs / test git / workspace $ git pull 
输入密码'/var/lib/jenkins/.ssh/id*_rsa'的密码:
已经是最新的。

到目前为止,我已经遵循了这封信的说明。问题是Jenkins作业失败,出现以下错误:

 状态码128:
stdout:
stderr:权限被拒绝(publickey)。
致命:远程终端意外挂起

这是我得到的同样的错误,当我打错密码(但当然,詹金斯并没有要求我输入密码)。以下几页:



表示ssh-agent可以帮助记住密码,我使用我自己的用户,但不是 jenkins ID。请注意,以普通用户身份运行时将产生以下结果:

$ p $ echo $$ SSH_AUTH_SOCK
/ tmp / keyring-nQlwf9 / ssh

运行与我的'jenkins'相同的命令时不会产生任何结果(甚至不允许权限) p>

我对问题的理解是密码不被记住。
你有什么想法吗?
我应该为jenkins用户启动一个ssh-agent还是key ring manager?怎么样?
或者当转发到同一台机器时是否适合ssh转发?
任何更明智的主意?



ps:我从来没有 sudo gitted 詹金斯或我的用户帐户(正如此处所述 - Ubuntu / GitHub SSH密钥问题

解决方案

由于没有人在评论中写了几个月的答案,我很快就会这样做。 b
$ b

有两种可能的问题/解决方案:


  1. 用错误的用户创建的id_rsa

    p>

    创建id_rsa作为jenkins用户(请参阅 hudson无法从git仓库中获取


  2. 将密码空置为空



Here is my setup:

  1. Jenkins is running on my linux machine as 'jenkins' user.
  2. I have generated a ssh key-pair as described in Linux - Setup Git, for the 'jenkins' user.
  3. When I sudo su jenkins and try ssh -vT git@github.com, I am always asked my passphrase, but I am always eventually authenicated. (the verbose option shows which key is used, among others).
  4. I could clone my repo from GitHub using jenkins:

Thusly:

jenkins@alpm:~/jobs/test git/workspace$ git pull 
Enter passphrase for key '/var/lib/jenkins/.ssh/id*_rsa':
Already up-to-date.

Up to this point I have followed the instructions to the letter. The problem is that the Jenkins job fails with the following error:

status code 128:
stdout: 
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

This is same error as I get when I typo the passphrase (but of course, Jenkins does not ask me for the passphrase). The following pages:

indicate to me that ssh-agent could help remember the passphrase, which it does when I am using my own user, but not the jenkins id. Note that while running as my normal user yields:

echo "$SSH_AUTH_SOCK"
/tmp/keyring-nQlwf9/ssh

While running the same command as my 'jenkins' yields nothing (not even permission denied)

My understanding of the problem is that the passphrase is not remembered. Do you have any idea? Shall I start a ssh-agent or key ring manager for the jenkins user? How? Or is ssh forwarding suitable when forwarding to the same machine? Any brighter idea?

ps: I never sudo gitted, I always used jenkins or my user account (as mentioned in this SO post - Ubuntu/GitHub SSH Key Issue)

解决方案

Since nobody wrote the answer from the comments for several months, I will quickly do so.

There are 2 possible problems/solutions:

  1. id_rsa created with wrong user

    Create id_rsa as the jenkins user (see hudson cannot fetch from git repository)

  2. Leave passphrase empty

这篇关于在使用Ubuntu上的Jenkins用户从GitHub获取权限时,权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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