I have the following .gitlab-ci.yml
file, which aims to deploy my master GitLab repository by cloning it to the test
directory on a specific server.
image: ubuntu:latest
before_script:
- apt-get install -y
- apt-get update -y
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y && apt-get install git -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null ## /dev/null = trou noir
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan charrier.alwaysdata.net >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
deploy:
script:
- ssh -o StrictHostKeyChecking=no -vT user_name@xxx.xx.xxx.xxx "cd test && git clone git@gitlab-myweb.com:repo_group/repo.git"
only:
- master
The $SSH_PRIVATE_KEY
is the private key generated when logged in as user_name
in the xxx.xx.xxx.xxx
, where I am trying to clone my repo.
Upon running the ci
, I get this error:
user_name@xxx.xx.xxx.xxx: Permission denied (publickey).
ERROR: Job failed: exit code 1
I have clearly messed up the ssh
, but I am very confused what exactly is my issue.
I was loosely following this guide.
Can you help me find my error?