Gitlab CI/CD在通过ssh:连接到Digital Ocean Droplet时失败
这是我的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 *ntStrictHostKeyChecking nonn" > ~/.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
当我触发这个时,我得到以下错误
$ 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
我还在CI/CD变量中保存~/.ssh/id_rsa。任何人都知道这个错误为什么会出现并失败。
我用OPENSSH生成的密钥,而不是在RSA中生成的密钥。在RSA中我生成密钥后,问题已修复