Git |詹金斯|权限被拒绝(公钥) [英] Git | Jenkins | Permission denied (publickey)
问题描述
我们有一个通用的LDAP帐户/用户.我们计划使用该用户为我们的团队配置Jenkins.
We have a common LDAP account/user. We plan to use this user to configure Jenkins for our team.
- 我使用登录名登录到计算机/VM,并安装了Jenkins.
- 然后,我仅从我的帐户生成了ssh密钥,但是在生成ssh密钥时提供的电子邮件ID是普通用户.
- 然后我将公共ssh密钥添加到GitHub(在Github中,我使用普通用户登录).
- 向Jenkins SSH凭据插件添加了私钥.
- 创建了一个可以轮询SCM的工作,并且工作正常.
- 我需要执行一些git命令(即pull,checkout,tag等...).因此,我正在编写蚂蚁脚本来实现这一目标.
- 当我通过詹金斯执行GIT ant目标[1]时,出现以下错误:
获取:[回声] ---------------------------------------------------------
fetch: [echo] ---------------------------------------------------------
[echo]从git@github.XYZ.com:XYZ/ABC主站获取最新消息
[echo] Fetching Latest from git@github.XYZ.com:XYZ/ABC master
[回声] ---------------------------------------------------------
[echo] ---------------------------------------------------------
[exec] git@github.XYZ.com:权限被拒绝(公钥).
[exec] git@github.XYZ.com: Permission denied (publickey).
[exec]致命:无法从远程存储库读取.
[exec] fatal: Could not read from remote repository.
[exec]
[exec]请确保您具有正确的访问权限
[exec] Please make sure you have the correct access rights
[exec]和存储库存在.
[exec] and the repository exists.
我是否必须使用普通帐户/用户登录到VM并生成ssh密钥,然后使用这些密钥?如果是,那么Point 5的运行状况如何呢?如果没有,那我在做什么错了?
Do I have to log in to the VM using common account/user and generate the ssh keys and then use those keys? If yes, then how come Point# 5 is working fine? If no, what is wrong I'm doing here?
推荐答案
Jenkins将使用与作业相关联的私钥来读取远程存储库.
Jenkins will use its private key associated with the job to read the remote repo.
但是:作业内部执行的脚本将使用运行Jenkins本身的用户中的默认SSH密钥:〜user/.ssh/id_rsa
But: the script executed within the job itself will use the default SSH key found in the user running Jenkins itself: ~user/.ssh/id_rsa
确保默认私钥是该作业所需的私钥(或者可以通过〜/.ssh/config
设置私钥):关键是,该私钥不再与Jenkins SSH凭据插件.
Make sure the default private key is the one you need for that job (or you can set one through ~/.ssh/config
): the point being, this is no longer related to the Jenkins SSH Credential plugin.
这篇关于Git |詹金斯|权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!