GitLab CI/CD Job fail Permission denied (publickey,password).
I am trying to deploy my app from the git repository into my droplet.
I have generated a key pair, added it to the authorized_keys on the Droplet. Tested the ssh connection with gitlab via the
ssh -T email@example.com command.
Also I have encoded the privateKey in base64 and added it to the GitLab CI/CD Variables.
Using the following .gitlab-ci.yml
image: keymetrics/pm2:6 stages: - deploy deploy_staging: stage: deploy script: - echo "====== Deploy to development server ======" - apk update && apk upgrade - apk add git openssh bash # Add target server`s secret key - mkdir ~/.ssh - echo $TARGET_SERVER_SECRET_KEY_BASE64_DEVELOPMENT | base64 -d > ~/.ssh/id_rsa - chmod 700 ~/.ssh && chmod 600 ~/.ssh/* - echo "Test ssh connection" - ssh -o StrictHostKeyChecking=no -T "ubuntu@$TARGET_SERVER_HOST_DEVELOPMENT" # Delploy - echo "Setup tagget server directories" - pm2 deploy ecosystem.config.js staging setup 2>&1 || true - echo "make deploy" - pm2 deploy ecosystem.config.js staging environment: name: deploying only: - development
But I always get the following response
Test ssh connection $ ssh -o StrictHostKeyChecking=no -T "ubuntu@$TARGET_SERVER_HOST_DEVELOPMENT" Warning: Permanently added '126.96.36.199' (ECDSA) to the list of known hosts. Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). ERROR: Job failed: exit code 255
Is there something I am missing here?
Thanks in advance
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×