我无法使用gitlab CE管道进行部署:
image: node:alpine
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
stages:
- test
- build
- deploy
before_script:
- npm install
test:
stage: test
script:
- npm test
tags:
- docker
- primary
build:
stage: build
script:
- npm run build
tags:
- docker
- primary
artifacts:
name: "$CI_COMMIT_REF_SLUG"
when: on_success
paths:
- build/
expire_in: 1 hour
deploy:
stage: deploy
script:
- apk add --no-cache rsync openssh
- mkdir -p /root/.ssh
- echo "$PLF_SPA_DEV_SSH_KEY"
- echo "$PLF_SPA_DEV_SSH_KEY" >> /root/.ssh/id_rsa
- chmod 600 /root/.ssh/id_rsa
- cat /root/.ssh/id_rsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
- scp -i /root/.ssh/id_dsa -v -r build/ gitlab@67.205.XXX.XX:/var/www/plf/
tags:
- docker
- primary
dependencies:
- build
我已经在主机上为用户gitlab
生成了密钥,并将私钥作为变量保存在gitlab CI / CD中。
我已为要写入主机gitlab
的主机上的文件夹授予适当的权限
这是在Jobs
控制台中出现的错误:
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /root/.ssh/id_rsa
debug1: Will attempt key: /root/.ssh/id_dsa
debug1: Will attempt key: /root/.ssh/id_ecdsa
debug1: Will attempt key: /root/.ssh/id_ed25519
debug1: Will attempt key: /root/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Trying private key: /root/.ssh/id_xmss
debug1: No more authentication methods to try.
gitlab@67.205.XXX.XXX: Permission denied (publickey).
lost connection
ERROR: Job failed: exit code 1