2

On my server I have a post-receive in hooks with this code

git push --mirror origin

(Origin is : git remote add origin git@gitlab.com:myproject/myproject.git)

If I execute this file on the server it works but if I on my local machine does a

git push live

I get this error:

Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Votre branche est en avance sur 'origin/master' de 1 commit.
remote:   (utilisez "git push" pour publier vos commits locaux)
remote: Permission denied (publickey).
remote: fatal: Could not read from remote repository.
remote: 
remote: Please make sure you have the correct access rights
remote: and the repository exists.
To ssh://myserver/var/www/html/myproject/myproject.git

I understand that this is a permission problem but I don't understand which permissions that should be changed.

My keys seems to have the right permissions :

server$ chmod 700 ~/.ssh
server$ chmod 600 ~/.ssh/authorized_keys

This is the output when I execute post-receive on the server:

./hooks/post-receive 
Votre branche est en avance sur 'origin/master' de 1 commit.
  (utilisez "git push" pour publier vos commits locaux)
Décompte des objets: 3, fait.
Delta compression using up to 2 threads.
Compression des objets: 100% (3/3), fait.
Écriture des objets: 100% (3/3), 286 bytes | 0 bytes/s, fait.
Total 3 (delta 2), reused 0 (delta 0)
To git@gitlab.com:myproject/myproject.git
   3ae70c6..6e7c1d8  master -> master)
flaggalagga
  • 451
  • 5
  • 14
  • Could it be that you need a `pull` first? See the 6th line. – Christoph Jan 18 '17 at 15:30
  • I added the output code when I execute "post-receive" on my server. As you can see it's not the problem – flaggalagga Jan 18 '17 at 15:44
  • 1
    Does `git remote show live` give any information? – Christoph Jan 18 '17 at 15:55
  • With `git remote show live` On my local machine I get `* remote live Fetch URL: ssh://myserver/pathtogit/myproject.git Push URL: ssh://myserver/pathtogit/myproject.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date)` – flaggalagga Jan 18 '17 at 16:30
  • Can you create a dummy project and reproduce the error there? Then you could share that project in order to get a reproducible example. By the way: The server is not down at the moment? – Christoph Jan 18 '17 at 16:47
  • We'll the permission problem lies on our live server so I'm not sure who I could do this for you to test. The Git "chain" is as follows My local computer (`git push live`) => Our Live Server (`git push --mirror origin` in hooks/post-receive) => GitLab – flaggalagga Jan 19 '17 at 14:56
  • Firewall issue? Does [that](http://stackoverflow.com/questions/11041729/why-does-github-recommend-https-over-ssh) help? – Christoph Jan 19 '17 at 15:10
  • Not sure it is a Firewall issue since the code partly works. The push to Our live server works from my local computer but not the push to Gitlab (hooks/post-receive) . But if I execute ./hooks/post-receive on the live server it works. – flaggalagga Jan 20 '17 at 05:57

0 Answers0