No upload access after authenticating with SSH

Hello!

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:

deploy_test:
  stage: deploy
  image: ubuntu:latest
  tags:
    - docker-bind
  script:
    - 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 user.email <email>
    - git config user.name <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
  environment:
    name: testing
    url: <url>
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

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