So I have a post-receive script inside a remote repository in a private server. What I want is to perform a push to github every time the remote repo receive a push. I do this so that it can first go through some security checks, like making sure they don't change stuff in master branch, etc.
This is the script:
#!/bin/sh
git --work-tree=/var/www/html/beta --git-dir=/var/repo/beta.git checkout -f
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
git push git@github.com:kevuno/mycoolrepo.git $current_branch
Where my coolrepo is a private repo inside GitHub.
I can perform manual pushes inside the repo located on the remote server because I have already added the SSH keys so ssh authentication works all fine. However, if I try to push from the post-receive hook it suddenly just doesn't work. This is the error I get
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.
Any help would be appreciated.