我有一个git存储库,该存储库使用SSH密钥对用户进行身份验证,我想将该存储库用作GoCD资料。 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密钥添加到GoCD?

最佳答案

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

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

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

sudo作为“go”用户并创建密钥
$ 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也会给您同样的错误。

现在将密钥添加到git服务器,然后在GoCD中单击“检查连接”。它应该显示“连接正常”。

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

07-27 19:14