git - 如何设置 GoCD 来处理使用 SSH key 进行身份验证的私有(private) git 存储库?

标签 git ssh continuous-integration go-cd

我有一个 git 存储库,它使用 SSH key 对用户进行身份验证,我想将该存储库用作 GoCD Material 。 GoCD 给我这个错误:

Error performing command: --- Command ---
git ls-remote ssh://git@server/repo.git refs/heads/master
--- Environment ---
{GIT_ALLOW_PROTOCOL=http:https:ssh:git:file:rsync}
--- INPUT ----

--OUTPUT ---

--- ERROR ---
STDERR: Host key verification failed.
STDERR: fatal: Could not read from remote repository.
STDERR: 
STDERR: Please make sure you have the correct access rights
STDERR: and the repository exists.
---

有什么方法可以将 SSH key 添加到 GoCD?

最佳答案

在撰写此答案时,无法直接在 GoCD 中管理 SSH key 。要使其工作,您必须为 GoCD 服务器和所有代理生成 SSH key ,然后将它们添加到托管 git 存储库的服务器。您还可以将现有 key 复制到服务器和节点,但显然不推荐这样做。

例如,对于标准的 GoCD 服务器安装,您的系统中应该有“go”用户:

$ grep GoCD /etc/passwd
go:x:998:998:GoCD User:/var/go:/bin/bash

sudo 作为“go”用户并创建 key

$ sudo su - go
$ ssh-keygen
...
$ ssh [server]
The authenticity of host '[server] ([1.3.3.7])' can't be established.
ECDSA key fingerprint is SHA256:Rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[server]' (ECDSA) to the list of known hosts.
Permission denied (publickey,keyboard-interactive).

最后一步很重要,因为如果你没有成功,GoCD 会给你同样的错误。

现在将您的 key 添加到 git 服务器并单击 GoCD 中的“检查连接”。它应该打印“连接正常”。

为运行代理的每个节点和用户生成 key 。

关于git - 如何设置 GoCD 来处理使用 SSH key 进行身份验证的私有(private) git 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43171897/

相关文章:

git - 如何根据选项名称确定要在全局配置文件中使用的正确 git 配置设置?

php - Composer 与私有(private)存储库的多级依赖

linux - 建立 VPN 连接后 SSH 连接搞砸了

docker - 使用 CircleCI 的预建镜像与拉取私有(private)镜像之间的权衡是什么?

windows - Windows 上的 Jenkins - Matlab 不退出

ruby-on-rails - Travis CI + ruby​​ on Rails 包安装

git - 一个分支和从它创建的另一个分支是否会继承彼此的更改?

git - 如何找到远程 git 存储库的默认分支?

ssh wget 下载 jdk

git - 重新验证 git(强制为新用户创建新的 SSH key )