No upload access after authenticating with SSH


I’m trying to make a job that merges to TEST branch after marging to main, but I’m having problems with pushing code to the repository.

Heres the code:

  stage: deploy
  image: ubuntu:latest
    - docker-bind
    - apt-get update -y
    - apt-get install -y git openssh-client
    - eval $(ssh-agent -s)
    - chmod 600 "$SSH_KEY"
    - ssh-add "$SSH_KEY"
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh

    - git config <email>
    - git config <name>

    - ssh-keyscan <host> >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - git checkout $TEST_BRANCH
    - git merge origin/master
    - git push origin $TEST_BRANCH
    name: testing
    url: <url>

The job dies at git push and throws the following error: remote: You are not allowed to upload code.

The SSH key is valid, because it’s my personal one which I use for development. I have maintainer access, so I’m confused as to why it doesn’t allow me to push code.

Hi @cubex ,

origin remote in GitLab CI is using HTTP URLs, if you want to use SSH to push to repository you need to modify the origin to SSH URL or create additional remote using SSH URL and use that.

1 Like