1

So I've setup a git pull Webhook from my server.

When I run a test I'm ending with :

Host key verification failed. fatal: The remote end hung up unexpectedly

However I have a ssh-key well inserted since I can git pull from the directory.

Edit :

Okay so I think it is due to apache user problem.

I tried to sudo -u www-data git pull origin master but I have the following error :

Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).

With those permission :

root@vps362370:/var/www/.ssh# ls -al
total 16
drwxr-xr-x 2  777 root 4096 Feb  3 14:58 .
drwxr-xr-x 3 root root 4096 Feb  3 10:06 ..
-rw------- 1  777 root 1675 Feb  3 14:48 id_rsa
-rw------- 1  777 root  404 Feb  3 14:48 id_rsa.pub
-rw------- 1  777 root    0 Feb  3 14:58 know_hosts
root@vps362370:/var/www/.ssh# cd ../
root@vps362370:/var/www# ls -al
total 12
drwxr-xr-x  3 root root 4096 Feb  3 10:06 .
drwxr-xr-x 14 root root 4096 Feb  3 12:41 ..
drwxr-xr-x  2  777 root 4096 Feb  3 14:58 .ssh

What kind of permission should be set? (I tried 777 or 600 but none seems to work).

Edit 2 :

I've manage to add git to my known host by usermod -a -G www-data root Then

chgrp www-data /var/www/.ssh
chmod g+rwxs /var/www/.ssh
chmod 777 /var/www/.ssh/known_host

But now I got :

Permission denied (publickey).

Even after specifically adding my /var/www/.ssh/id_rsa.pub to github deploy key.

My .git/config file :

root@vps362370:/var/Smart-Pix# cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com:Smart-Pix/Smart-Pix.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
Baldráni
  • 5,332
  • 7
  • 51
  • 79
  • Have you tried ssh with verbose options from toe server to the repo server? It might help you identifying communication problems. – Tom Feb 03 '17 at 11:29
  • Hum the thing is I do not connect to the server but only send a Post Request when pushing. I don't see where I could use verbose for debugging purpose :/ – Baldráni Feb 03 '17 at 11:33
  • Possible duplicate of [BitBucket: Authentication failed](http://stackoverflow.com/questions/41692721/bitbucket-authentication-failed) – Jakuje Feb 03 '17 at 11:35
  • Does this means you clone with HTTPS? In this case the SSH key is not used. – Tom Feb 03 '17 at 11:35
  • @Tom Nup nup, I'm never using https – Baldráni Feb 03 '17 at 11:40
  • The fact you are dealing with `/var/www` means you are using HTTP for communications with the remote repo. HTTP does not use SSH keys, it uses login + password or a similar authentication. I don't think it is a good idea to have a `.ssh/` folder in `/var/www`, and in any case `.ssh/`folder must have 700 permissions. What is the content of your local `.git/config` file? – Tom Feb 03 '17 at 15:29
  • I do not really had the choice for the folder. It is automatically set to this. I've edited with my config – Baldráni Feb 03 '17 at 15:34

0 Answers0