Gitlab CI 使用 ed25519 私钥

Gitlab CI use ed25519 private key

我正在尝试在远程服务器上的 Gitlab CI 中做一些事情。使用 RSA 密钥时一切正常,但当我尝试使用 ED25519 密钥时,我卡住了:

Running with gitlab-ci-multi-runner 9.3.0 (3df822b)
  on Internal Runner (079281fd)
Using Docker executor with image 1drop/docker:git ...
Using docker image sha256:b9cf0ca386341048f8696d950123e20b5d6583c190f266aacb25b6d3d4736028 for predefined container...
Pulling docker image 1drop/docker:git ...
Using docker image 1drop/docker:git ID=sha256:966d107d59806ab1a3aa2229618858b5141e2c7bb183dd9f4dfaafdca4d51774 for build container...
Running on runner-079281fd-project-207-concurrent-0 via srv1...
Fetching changes...
$ eval $(ssh-agent -s)
Agent pid 17
$ ssh-add <(echo "$SSH_PRIVATE_KEY"| base64 -d)
Enter passphrase for /dev/fd/63: ERROR: Job failed: exit code 1

如您所见,如果 Gitlab 将 SSH_PRIVATE_KEY 变量注入运行时出现问题,我已经尝试使用 base64 对 ed25519 密钥进行编码。
key的内容没问题,我可以输出出来,本地测试一下,可以。此外,如果我将常规 RSA 密钥放入 SSH_PRIVATE_KEY 变量中,它也能完美运行。但是在某些客户服务器上,我需要使用 ed25519 并且我一直收到这个 "enter passphrase" 东西,我不知道为什么。

我需要安装一些库才能运行吗?我的 ssh 模块说它可以做 ed25519 密钥。

文档已更新。参见 https://docs.gitlab.com/ee/ci/ssh_keys/

  ##
  ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  ## We're using tr to fix line endings which makes ed25519 keys work
  ## without extra base64 encoding.
  ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  ##
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null

使用这个命令对我有用。