Gitlab CI使用ed25519私钥 [英] Gitlab CI use ed25519 private key

查看:163
本文介绍了Gitlab CI使用ed25519私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to do some stuff within Gitlab CI on a remote server. When using RSA keys everything works fine, but when I try using ED25519 keys, I'm stuck:

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密钥进行编码.
密钥的内容很好,我可以将其输出并在本地对其进行测试,并且可以正常工作.另外,如果我将常规RSA密钥放入SSH_PRIVATE_KEY变量中,它也可以很好地工作.但是在某些客户服务器上,我需要使用ed25519,并且不断收到输入密码"字样,而我不知道为什么.

As you can see I already tried encoding the ed25519 key using base64 if something would go wrong when Gitlab is injecting the SSH_PRIVATE_KEY variable into the runtime.
The content of the key is fine, I can output it and test it locally and it works. Also if I put a regular RSA key into the SSH_PRIVATE_KEY variable, it works perfectly. But on some customer servers I'm required to use ed25519 and I keep getting this "enter passphrase" stuff and I don't know why.

我是否需要安装一些库才能使其正常工作?我的ssh模块说它可以执行ed25519键.

Do I need to install some libraries in order for this to work? My ssh module says it can do ed25519 keys.

推荐答案

文档已更新.请参阅 https://docs.gitlab.com/ce/ci/ssh_keys/README. html

  ##
  ## 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

使用此命令对我有用.

这篇关于Gitlab CI使用ed25519私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆