3

我们有一个共同的 LDAP 帐户/用户。我们计划使用此用户为我们的团队配置 Jenkins。

  1. 我使用我的登录名登录到机器/VM 并安装了 Jenkins。
  2. 然后我只从我的帐户生成了 ssh 密钥,但我在生成 ssh 密钥时提供的电子邮件 ID 是普通用户。
  3. 然后我将公共 ssh 密钥添加到 GitHub(在 Github 中我使用普通用户登录)。
  4. 将私钥添加到 Jenkins SSH 凭证插件。
  5. 创建了一个轮询 SCM 的作业,它运行良好。
  6. 我需要执行一些 git 命令(即 pull、checkout、tag 等...)。因此,我正在编写 ant 脚本来实现这一点。
  7. 当我通过 Jenkins 执行 GIT ant 目标 [1] 时,出现以下错误:

获取:[回声] --------------------------------------------- ------------

[echo] 从 git@github.XYZ.com:XYZ/ABC master 获取最新消息

[回声] ----------------------------------------------------------- ----------

[exec] git@github.XYZ.com:权限被拒绝(公钥)。

[exec] 致命:无法从远程存储库读取。

[执行]

[exec] 请确保您拥有正确的访问权限

[exec] 并且存储库存在。


我是否必须使用通用帐户/用户登录 VM 并生成 ssh 密钥然后使用这些密钥?如果是,那么第 5 点如何正常工作?如果不是,我在这里做错了什么?

[1] -在 Jenkins Git 插件中指定 git 命令

4

1 回答 1

1

Jenkins will use its private key associated with the job to read the remote repo.

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

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.

于 2019-01-22T05:53:41.837 回答