Gitlab returning remote: You do not have permissions to do this. while performing scripted git push

My scenario is as follows:

we have a gitlab set up for our team where we do all of our development with branches etc, etc. We also have an official repo hosted by our company where we would like to have our master branch mirrored so that people (that have access to this repo in our company) can view our code.

I have written a post-receive hook that would mirror commits pushed to master branch on gitlab towards the official repo: (/opt/gitlab/embedded/service/gitlab-shell/hooks/post-receive on gitlab)

# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.
ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH']

#!/usr/bin/env ruby

# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.

from, to, branch = " "
if (branch =~ /master$/) == nil
    puts "Received branch #{branch}, not deploying."

`git remote add deveo #{deveo_server} >/dev/null 2>&1`
`git push deveo master`
 puts "DEPLOY: master(#{to}) mirrored to '#{deveo_server}'"

refs =
key_id  = ENV['GL_ID']
repo_path = Dir.pwd

require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/gitlab_post_receive'

if, key_id, refs).exec &&, repo_path)
  exit 0
  exit 1

The problem is that when I do this I receive the following on commits to gitlab's master branch:

[master aa4a4f2] testing hooks 7
 0 files changed
 create mode 100644 testing_hooks_7
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 264 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: You do not have permissions to do this.
remote: fatal: Could not read from remote repository.
remote: Please make sure you have the correct access rights
remote: and the repository exists.
remote: DEPLOY: master(aa4a4f218b7bc335ee3e0d6d52df5cfd5ddc1c99) mirrored to ''
   1e92695..aa4a4f2  master -> master

I have launched ssh agent there and added git user's ssh from gitlab to deveo but something is missing.

This has worked when I set up this with bare repo next to my local repository on my local machine - so there has to be some keys missing somewhere.. but where :( ?


Ok so the problem was that the bot (in deveo) that I have created was a read-only bot. I needed to go to in deveo to project options->Settings and bot accounts->bot->give this bot write permissions to repositories.

And of course I needed to add git user ssh key (from gitlab's host) to deveo.

Now it works fine :)


 ? Mirroring from Gitlab to Github
 ? Permission denied (publickey) on capifony deployment from windows with remote host gitlab
 ? Unable to connect to Gitlab Container on Custom Port via SSH
 ? Centos 6.8 - Updates repo issues
 ? Centos 6.8 - Updates repo issues
 ? Centos 6.8 - Updates repo issues
 ? installing multiple gcc on centOS 7
 ? yum update error in centos 6.6
 ? Yum just stopped woiking and gives error
 ? Develop iOS swift app to mirror into a browser?