Git post-update hook not working properly

1

If I push to my remote origin repository the post-receive hook should push all to another remote repository on another machine.

When I push to my origin the post-receive hook gets triggered but I always get the following error message.

remote: post-update started remote: Host key verification failed. remote: fatal: Could not read from remote repository. remote: remote: Please make sure you have the correct access rights remote: and the repository exists. remote: post-update end

Content of post-receive hook:

#!/bin/sh
echo "post-update started"
git push --mirror git@<server IP>:root/sample.git
echo "post-update end"

I have created a ssh key for my normal user and git user and both were added to authorized keys file.

Something must be missing , but I do not know what?!

Matthias Reisner

Posted 2014-08-08T08:05:04.530

Reputation: 173

Answers

0

The SSH error suggests that the fingerprint of the server's key hasn't been imported in the .ssh/known_hosts file yet. You can do this by running ssh git@<server IP> manually as the git user on the git server once.

Alternatively you can tell SSH not to check the host key by using the following ssh options:

UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no

You can add these in your .ssh/config file.

mtak

Posted 2014-08-08T08:05:04.530

Reputation: 11 805