SSHトンネルを介してgitosisサーバに接続します
質問
私はこのように、私のMacBook上のSSHトンネルのセットアップを持っている...
$ ssh -o ServerAliveInterval=3 -N -L 22222:gitosis-server:22 user@firewall.domain.com
だから私は、ローカルホストへのSSHことができます:22222およびファイアウォールの背後てgitosis-サーバになってしまいます。
私は
...、ローカルid_rsa.pubファイルを作成してgitosisサーバ(Centos5を実行している)にそれをコピーして、使用してgitosisにインポートしました# sudo -H -u gitosis gitosis-initIt was successful as I can see the public key in /var/lib/gitosis/.ssh/authorized_keys.
Back on my macbook I setup a ~/.ssh/config file with the following...Host gitosis-server Hostname localhost HostKeyAlias gitosis-server.domain.com Port 22222So...I'm thinking this command should work...
$ git clone gitosis@gitosis-server:gitosis-admin.gitIt does not however as it comes up asking for a password....when the public keys should be working.
Initialized empty Git repository in /Users/USER/Development/gitrepo/gitosis-admin/.git/ gitosis@localhost's password:Any ideas on getting git working through to a gitosis server behind a firewall?
Thanks,
Matt
EDIT - Adding Debug From SSH Attempt
I did this command, 'ssh -vvv gitosis@gitosis-server'. I get some debugging back and it doesn't seem to like my Identity.
debug2: key: /Users/USER/.ssh/id_rsa.gitosis (0x1019b0) debug1: Authentications that can continue: publickey,gssapi-with-mic,password debug3: start over, passed a different list publickey,gssapi-with-mic,password debug3: preferred publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering public key: /Users/USER/.ssh/id_rsa.gitosis debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-with-mic,password debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password gitosis@localhost's password:
EDIT 2
OK...Definately a bad key. I double checked all my keys again and of course found the gitosis-server was holding a bad key in the authorized_keys file.
debug1: userauth-request for user gitosis service ssh-connection method none debug1: attempt 0 failures 0 debug1: PAM: initializing for "gitosis" debug1: PAM: setting PAM_RHOST to "firewall.domain.com" debug1: PAM: setting PAM_TTY to "ssh" debug1: userauth-request for user gitosis service ssh-connection method publickey debug1: attempt 1 failures 1 debug1: test whether pkalg/pkblob are acceptable debug1: temporarily_use_uid: 102/103 (e=0/0) debug1: trying public key file /var/lib/gitosis/.ssh/authorized_keys debug1: restore_uid: 0/0 debug1: temporarily_use_uid: 102/103 (e=0/0) debug1: trying public key file /var/lib/gitosis/.ssh/authorized_keys2 debug1: restore_uid: 0/0 Failed publickey for gitosis from FIRE.WALL.IP.ADDRESS port 52453 ssh2
私が使ってgitosisサーバ上のauthorized_keysファイルをよく見ていた....それは間違っていました。私は、二重、私は私のワークステーションからの/ tmpにコピーした公開鍵ファイルをチェックし、それは正しいものでしたが、authorized_keysにしていたものとは異なります。私は、サーバー上のauthorized_keysファイルを削除し、 'sudoの-H -uてgitosisてgitosis-のinit
私はauthorized_keysに編集して、正しいキーを追加することによって、手動で更新した後、私はそれは、1回のまたは2つの試行のためのトンネルを通って、私のワークステーションから動作するようになりました。そして、それはこれまでと同様に動作を停止しました。私が使ってgitosisが戻って動作しない古いキーにそれを戻っていた....てgitosisサーバー上のauthorized_keysファイルに再度行き、十分に確認してください。
なぜそれがこれをやっている....私は、上記のコマンド...それを変更することができなかったでそれを追加しようとした後でさえも....バック悪い公開鍵に戻す....そして、それを手動で変更しました。 ...これは働いていたが、Gitはその後、再び悪いものに戻っています。
これは使ってgitosisが、私はそこに置く最初のキーを覚える続けるようなものだ....と私は修正キーに変更することはできません。
イライラ...
マット
解決
をフォロー:の
悪いの公開鍵を再利用することを主張してgitosisなぜ私はよく分かりません。正しいキー動作しませんでしたを取るためにそれを強制しようとします。
だから、今日私はちょうど除去され、私のCentOS5ボックスに使ってgitosisパッケージを再インストールしました。
yum remove gitosis rm -rf /var/lib/gitosis yum install gitosis sudo -H -u gitosis gitosis-init < /tmp/id_rsa.gitosis.pub #the correct key
私のMac上で、私はトンネルのローカルホストをSSH:使ってgitosis-サーバにファイアウォールを経由して22222:22。
$ ssh -o ServerAliveInterval=3 -N -L 22222:gitosis-server:22 user@firewall.domain.com
私のMacでは、私はこのようになりますの〜/ .ssh / configに作成しました...
Host gitosis-server Hostname localhost IdentityFile ~/.ssh/id_rsa.gitosis HostKeyAlias gitosis-server.domain.com Port 22222
すると...このサイトの指示に従って...
のhttp:/ /scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-wayする
...すべての後に... を「ここにいくつかのクールな魔法が起こるローカルマシン上でこれを実行します。」を...だけで動作します...ユーザー名「gitのを」置き換えることを忘れないでください除き"使ってgitosis" と。
すべてのナンセンスは誰かに役立ちます願っています。おかげでも、私がここに来た提案を....それは、問題を絞り込む助けます。
マット
他のヒント
似たような状況のための私のセットアップ(作業)
私はによってブロックされ、いくつかの理由のヌル・ルートのためである repo.or.cz のための同様の設定を(持っています私が使用するISP、ポーランドのISP Telekomunikacja SA(tpnet))、そしてそれは私のために動作します:
私は、接続しようとする前に、SSHのTUNELを設定するには、次のコマンドの実行を実行します:
$ autossh -M 20000 -f -N -L 2222:repo.or.cz:22 user@gateway.example.com
(私は、私は、すなわち、接続を維持するために、切断されていない場合は再接続をautossh
の代わりssh
を使用します)。適切なアイデンティティはSSH認証エージェントに追加されていることを確認します:
$ ssh-add -l
2048 d7:d3:69:f5:0f:f9:5e:aa:e0:0b:28:c2:03:42:09:66 /home/user/.ssh/id_dsa_gateway.example.com (DSA)
1024 11:a2:29:fe:37:12:a7:33:c4:23:b0:e1:82:92:e0:6a /home/user/.ssh/id_dsa_repo.or.cz (DSA)
私は一度だけ、私のプライベートSSH鍵のパスワードを提供する必要がキーチェーンに使用します、ログイン時ます。
私は~/.ssh/config
で次のように設定している。
Host repo.or.cz # NoHostAuthenticationForLocalhost yes HostName localhost Port 2222
この設定は問題なく私のために動作します。
<時間>自分の状況をデバッグ
あなたの状況をデバッグするためとして、?
私が使用してゲートウェイにログインできる場合は、まず、私はSSHトンネルを設定することが可能かどうかをチェックするために、「SSH user@firewall.domain.com」をチェックします。あなたは、Linux上にある場合は、ゲートウェイし、確立された接続があるかどうかを確認する例netstat --tcp
のために使用することができます。他のオペレーティングシステムや環境であなたは、同様の有用性を見つけることができます。
あなたが使ってgitosisに正しく接続できるかどうか確認してください。 の(私は記憶が正しければ gitorious には、SSH経由でのアクセスを管理するために使ってgitosisを使っているので、私は例のgitoriousからの応答を使用以下)の
$ ssh gitosis@gitosis-server Need SSH_ORIGINAL_COMMAND Connection to closed.
これは上記と同様の何かをしていない場合(repo.or.czは「致命的な?:あなたは私はどう思いますかシェル」を返す!、GitHubには」こんにちはユーザーを返しますが正常に認証しましたが、GitHubにはありませんシェルアクセスを提供していない」)、それはで失敗する場合は、チェック "sshの-vてgitosis @てgitosis-サーバー":ます。
$ ssh -v gitosis@gitosis-server [...] debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /home/user/.ssh/id_dsa_gitosis-server debug1: Remote: Forced command: gitosis-server user [...] debug1: Authentication succeeded (publickey)
このは(まだ)ssh
問題git
の問題ではない。
ssh -v
どのような認証方法とキーに関する情報をデバッグするあなたを与えるだろうとして ssh
はあなたの友達です。
10のうち9回私はこれがキーファイルのパーミッションの問題であることがわかります。 ssh
は、「ユーザー」によってのみ書き込み可能であるためにあなたの.ssh
ディレクトリとあなたのid_rsa
ファイルを好きで、私のumaskは、デフォルトでは、グループ書き込み可能なファイルを可能にします。これはあなたのような状況の場合である場合ssh -v
はあなたを教えてくれます。
編集
それはあなたのアイデンティティを受け入れないのsshdサーバのように見えるん。私はあなたがリモートサーバへのアクセス権を持っているかどうか知りませんが、デバッグモードでsshd
サーバを実行することは役立つかもしれない。
このような何かを実行している特定のポートの1つの接続ができます(これは通常のsshd
サービスを中断しないように)と、デバッグ情報を出力します。これは、サーバーが自分の身元を好きではない理由をデバッグに役立つことがあります。
sshd -d -p 2022
あなたの「標準」のsshdサービスは追加パラメータを指定して実行されている場合だけでなく、デバッグバージョンにこれらを供給することを確認します。
あなたが成功しlocalhost:2222
へのSSHことができると言います。あなたは正しく~/.ssh/config
が設定されていることを確認するには、あなただけgitosis-server
へのSSHことができますか?
ssh gitosis-server
私は同様の問題を抱えていたし、私はそれを解決します:
[srydberg@zeus ~]$ echo $SSH_AUTH_SOCK
/tmp/keyring-KXX3Aw/ssh
[srydberg@zeus tmp]$ sudo rm -rf keyring-KXX3Aw/
たぶん、あなたの鍵はそこにキャッシュされたのですか?