I have below simple script in .gitlab-cl.yml file:
build_deploy_stage:
stage: build
environment: Staging
only:
- master
script:
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" >> ~/.ssh/id_dsa
- cat ~/.ssh/id_dsa
- chmod 600 ~/.ssh/id_dsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- cat ~/.ssh/config
- scp myfile.js user@example.com:~
But I get this error when job is run, executing the last line (scp command):
Warning: Permanently added 'example.com' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
I spent whole day but could not fix it. I verified that $PRIVATE_KEY exists. I generated key pair while logged into example.com copying the generated private to PRIVATE_KEY variable on gitlab. How to fix this problem?
Note that it is dsa key.