如何在 TeamCity 构建步骤中设置经过 SSH 身份验证的 git 命令
How to set up SSH authenticated git commands in a TeamCity build step
我需要在 TeamCity 构建步骤中执行 git 命令。
这些 git 命令需要使用基于 SSH 的 url 用于 git 存储库,以便作为 git 服务器的特权用户进行身份验证(因为这些 git 命令实际上会修改 git 存储库,而不仅仅是读取它)。
我知道 this question。
我已经有 VCS 结帐模式 "Automatically on Agent"。 VCS root 已正确配置 ssh 并且运行良好。
然而,作为 stated in the documentation,TeamCity
temporarily saves the key on the agent's file system and removes it after git fetch/clone is completed.
因此,即使 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
文件存在并且包含适当的 public 键。我还确认 C:\Users\systeamcityagent\.ssh
不包含任何私钥(如预期的那样)。
我是 运行 TeamCity Enterprise 9.1.3.
为此推荐的解决方案是什么?
Teamcity 9.1 引入了一个名为 SSH 代理的新功能,它允许您使用服务器存储的 SSH 密钥建立代理端 SSH 连接:
我需要在 TeamCity 构建步骤中执行 git 命令。
这些 git 命令需要使用基于 SSH 的 url 用于 git 存储库,以便作为 git 服务器的特权用户进行身份验证(因为这些 git 命令实际上会修改 git 存储库,而不仅仅是读取它)。
我知道 this question。
我已经有 VCS 结帐模式 "Automatically on Agent"。 VCS root 已正确配置 ssh 并且运行良好。
然而,作为 stated in the documentation,TeamCity
temporarily saves the key on the agent's file system and removes it after git fetch/clone is completed.
因此,即使 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
文件存在并且包含适当的 public 键。我还确认 C:\Users\systeamcityagent\.ssh
不包含任何私钥(如预期的那样)。
我是 运行 TeamCity Enterprise 9.1.3.
为此推荐的解决方案是什么?
Teamcity 9.1 引入了一个名为 SSH 代理的新功能,它允许您使用服务器存储的 SSH 密钥建立代理端 SSH 连接: