2013-10-27 8 views
9

自分のプライベートサーバをプライマリgitリモートにして、自動的にgithubにミラーリングしようとしています。私はthis articleを見つけました。ほとんどpost-receiveスクリプトのgit push --mirror(本質的に)で動作します。自己ホストのgitリポジトリをgithub.comにミラーリングする(auth failures)

私のアプローチは、デプロイメントキーを作成してセキュリティで保護し、それをすべてのリポジトリで構成する必要がない点で異なっています。

私のポスト受信スクリプトは、上記のブログ記事のように完全な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つのバリエーションが認証エラーで失敗するのはなぜですか?

+0

エラーはこれらの変更によって発生したもので、それ以外のものではありませんか? –

+0

はい。私は上記のすべての味をテストしましたが、コメントごとに、「正常に動作する」とマークされたものは確実に動作し、stdioの処理方法を一貫して変更すると失敗します。 –

+0

だから、問題は私のsshの設定で何かかもしれないようです。調査する。 –

答えて

1

おそらく、sshで冗長フラグを設定して何がうまくいかないかを調べることができます。

環境変数GIT_SSHを使用して、gitがssh接続を開くために使用するコマンドを置き換えることができます。 manページから:だから

GIT_SSH 
     If this environment variable is set then git fetch and git push 
     will use this command instead of ssh when they need to connect to a 
     remote system. The $GIT_SSH command will be given exactly two 
     arguments: the [email protected] (or just host) from the URL and the 
     shell command to execute on that remote system. 

     To pass options to the program that you want to list in GIT_SSH you 
     will need to wrap the program and options into a shell script, then 
     set GIT_SSH to refer to the shell script. 

のように見えます/tmp/verb-ssh内のスクリプト:

#!/bin/bash 
/usr/bin/ssh -vvv "[email protected]" 

、次に環境変数GIT_SSH=/tmp/verb-sshを設定すると、いくつかの有用なデバッグ情報を提供する必要があります。

+0

これは、デバッグ出力を得るための素晴らしいヒントです。私はまだ根本的な原因を理解することができませんが、私はちょうどKISSに行くと思うし、とにかく速いので、前景にgithubにプッシュを残す。 –

関連する問題