Hopefully I don't butcher this explanation of my setup. I am currently calling git push
to a bare repo on a remote machine to trigger a post-receive hook that looks like so:
cd /path/to/working/tree
git pull
gatsby build && gh-pages -d public/
Everything works as expected up until the deploy step where gh-pages
pushes the changes to GitHub Pages, through another repo on GitHub. I get a remote: Permission denied (publickey)
when the post-receive hook is triggered via a git push
from my local machine, however it succeeds when run on the remote machine directly.
I'm guessing that the execution of gh-pages
is being done by a different user when the hook is triggered from my local machine, despite my git remote
configuration specifying the correct remote user.
staging [remote_user]@[remote_ip]:/path/to/bare/repo.git (fetch)
staging [remote_user]@[remote_ip]:/path/to/bare/repo.git (push)
Any help would be appreciated!
I'm guessing that the execution of gh-pages is being done by a different user when the hook is triggered from my local machine
You could check that, by modifying the post-receive hook and add to it:
id -a
export GIT_SSH_COMMAND='ssh -Tv'
That way, you will see exactly what id, and what SSH keys are considered on that hook.