【问题标题】:How to set up SSH authenticated git commands in a TeamCity build step如何在 TeamCity 构建步骤中设置 SSH 身份验证的 git 命令
【发布时间】:2016-02-28 08:04:17
【问题描述】:

我需要在 TeamCity 构建步骤中执行 git 命令。

这些 git 命令需要为 git repo 使用基于 SSH 的 url,以便作为 git 服务器的特权用户进行身份验证(因为这些 git 命令实际上会修改 git repo,而不仅仅是读取它)。

我知道this question

我已经有 VCS 结帐模式“自动在代理上”。 VCS root 已正确配置 ssh 并且运行良好。

但是,作为stated in the documentation,TeamCity

将密钥临时保存在代理的文件系统中,并在 git fetch/clone 完成后将其删除。

因此,即使 TeamCity 在代理端结账期间正确使用了 SSH 密钥,该密钥在构建后期也有意无法访问。

但是我真的很想以后再使用密钥!

git 命令生成的输出是:

[06:12:29][Step 3/4] Permission denied (publickey).
[06:12:29][Step 3/4] fatal: Could not read from remote repository.
[06:12:29][Step 3/4] 
[06:12:29][Step 3/4] Please make sure you have the correct access rights
[06:12:29][Step 3/4] and the repository exists.

我已确认known_hosts 文件存在并包含适当的公钥。我还确认C:\Users\systeamcityagent\.ssh 不包含任何私钥(如预期的那样)。

我正在运行 TeamCity Enterprise 9.1.3。

对此有什么推荐的解决方案?

【问题讨论】:

  • 你让它工作了吗?我处于类似情况,我很难让 ssh 代理与我的 git push 一起工作。

标签: git ssh teamcity ssh-keys teamcity-9.0


【解决方案1】:

Teamcity 9.1 引入了一个名为 SSH 代理的新功能,允许您使用服务器存储的 SSH 密钥建立代理端 SSH 连接:

What´s New in TeamCity 9.1

【讨论】:

  • 您能否详细说明如何在命令行中使用代理或密钥。我仍然很难让它发挥作用。
  • 查看official docs,那里有很好的解释。您需要对 SSH 密钥有一些基本的了解,但仅此而已。
猜你喜欢
  • 2012-07-22
  • 2016-06-13
  • 2014-09-13
  • 2018-04-21
  • 2019-09-28
  • 2017-01-20
  • 2013-01-23
  • 1970-01-01
相关资源
最近更新 更多