I am trying to have my personal server be my primary git remote and automatically mirror that to github. I found this article which gets it mostly working with a post-receive
script that does git push --mirror
(essentially).
My approach is different in that I would like to avoid having to create and secure a deploy key and then configure it on every repository.
My post-receive script works correctly with most of the variants below as marked in the comments except when I do the full nohup + stdio redirection + backgrounding as in the blog article above, the authentication stops working.
GITHUB_USERNAME=focusaurus
BARE_PATH=$(pwd -P)
REPO_NAME=$(basename "${BARE_PATH}")
REPO_URL="ssh://[email protected]/${GITHUB_USERNAME}/${REPO_NAME}"
echo "About to mirror to ${REPO_URL}"
#hmm, this works
#git push --mirror "${REPO_URL}"
#this works, too
#nohup git push --mirror "${REPO_URL}"
#and this also works OK
nohup git push --mirror "${REPO_URL}" &
#but this fails with
#Permission denied (publickey).
#fatal: The remote end hung up unexpectedly
#Somehow ssh agent forwarding must get screwed up? Help me, Internet.
#nohup git push --mirror "${REPO_URL}" &>>/tmp/mirror_to_github.log &
#this is the one used in the blog post above but it also fails
# nohup git push --mirror "${REPO_URL}" &>/dev/null &
I have ssh agent forwarding which I believe is how the working versions work. So my question is why do those last 2 variations fail with authentication errors?
nohup git push --mirror "${REPO_URL}" >/dev/null 2>&1 &
? – Michaudgit push -v
doesn't seem to add any verbosity so I'm having trouble troubleshooting effectively. – Excitor