我想讓我的個人服務器成爲我的主要git遠程鏡像並自動將其鏡像到github。我找到了this article,它主要用於(本質上)的post-receive
腳本。將自己託管的git存儲庫鏡像到github.com(auth失敗)
我的方法不同之處在於我希望避免必須創建和保護部署密鑰,然後在每個存儲庫上對其進行配置。
我的post-receive腳本在下面的大部分變體中都可以正常工作,除非我在上面的博客文章中完成nohup + stdio重定向+背景時,身份驗證停止工作。
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 &
我有ssh代理轉發,我相信是工作版本的工作方式。所以我的問題是爲什麼最後2個變體會失敗並出現身份驗證錯誤?
你確定失敗是由這些改變引起的,而不是其他的嗎? –
是的。我已經測試了上述所有風格,並根據評論,被標記爲「可以正常工作」的那些可靠工作,然後只是改變stdio的處理方式一直導致失敗。 –
所以它看起來像這個問題可能是我的SSH配置中的東西。調查。 –