I’m trying to deploy code from a Gitlab repository into remote servers.
Running the pipeline, a Permission denied error shows up
$ ssh $SSH_USER@$SSH_HOST "cd $WORK_DIR && git checkout $PRELIVE_BRANCH && git pull && exit"
Load key "/root/.ssh/id_rsa": error in libcrypto
Permission denied, please try again.
Permission denied, please try again.
deployer@XXX: Permission denied (publickey,password).
For the deployer user I’ve created an SSH key and saved it into repository’s CI/CD variables (as SSH_PRIVATE_KEY).
I’ve also saved the public key into deployer’s .ssh/authorized_keys file.
This is the pipeline I’m running
stages:
- deploy
deploy:
image: alpine:latest
stage: deploy
only:
- prelive
before_script:
- apk update
- apk add openssh-client
- install -m 600 -D /dev/null ~/.ssh/id_rsa
- echo "$SSH_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
- ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
script:
- ssh $SSH_USER@$SSH_HOST "cd $WORK_DIR && git checkout $PRELIVE_BRANCH && git pull && exit"
after_script:
- rm -rf ~/.ssh
Am I missing something?