简体   繁体   English

Error loading key "/dev/fd/63: Error when trigger the CI/CD in Gitlab

[英]Error loading key "/dev/fd/63: Error when trigger the CI/CD in Gitlab

Gitlab CI/CD failed while connecting to the Digital Ocean Droplet, via ssh: Gitlab CI/CD 在通过 ssh 连接到 Digital Ocean Droplet 时失败:

This is my CI file这是我的 CI 文件

before_script:
  - apt-get update -qq
  - apt-get install -qq git
  # Setup SSH deploy keys
  - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  - eval $(ssh-agent -s)
  - ssh-add <(echo "${SSH_PRIVATE_KEY}" | base64 --decode | tr -d "\r")
  - mkdir -p ~/.ssh
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    
deploy:
  type: deploy
  environment:
    name: production
  script:
    - ssh root@xxx.xxx.xxx.xxx "cd /var/www/html/customer-web && git checkout master && git pull origin master && npm install && npm run build && exit"
  only:
    - master

when I trigger this, I'm getting the following error当我触发它时,我收到以下错误

$ eval $(ssh-agent -s)
Agent pid 267
$ ssh-add <(echo "${SSH_PRIVATE_KEY}" | base64 --decode | tr -d "\r")
Error loading key "/dev/fd/63": invalid format
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

and I am saving the ~/.ssh/id_rsa in CI/CD variable too.我也将 ~/.ssh/id_rsa 保存在 CI/CD 变量中。 any one have idea why this error comes and failed.任何人都知道为什么会出现此错误并失败。

The key i generated with OPENSSH, not in RSA after i generate the key in RSA the issue has been fixed我使用 OPENSSH 生成的密钥,而不是在 RSA 中生成的密钥后,我在 RSA 中生成了该问题已得到修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM