Git SSH エラー: 「ホストに接続: ファイル番号が不正です」 質問する

Git SSH エラー: 「ホストに接続: ファイル番号が不正です」 質問する

私はgit ガイドしかし、github に接続しようとすると、次のような奇妙な問題が発生します。

$ ssh -v [email protected]
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Documents and Settings/mugues/.ssh/config
debug1: Applying options for github.com
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: connect to address 207.97.227.239 port 22: Attempt to connect timed out without establishing a connection
ssh: connect to host github.com port 22: Bad file number

これは.sshの下の設定ファイルです

Host github.com
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile "C:\Documents and Settings\mugues\.ssh\id_rsa"
    TCPKeepAlive yes
    IdentitiesOnly yes

何か案が?

ベストアンサー1

私自身もこの問題を経験しましたが、自分にとって有効な解決策を見つけました。

エラーメッセージ:

    ssh -v [email protected]
    OpenSSH_5.8p1, OpenSSL 1.0.0d 8 Feb 2011
    debug1: Connecting to github.com [207.97.227.239] port 22.
    debug1: connect to address 207.97.227.239 port 22: Connection timed out
    ssh: connect to host github.com port 22: Connection timed out
    ssh: connect to host github.com port 22: Bad file number

MINGGW シェルを使用している Windows の場合にのみ、不正なファイル番号メッセージが表示されます。Linux ユーザーの場合は、タイムアウトが表示されます。

問題:

SSHはおそらくポート22でブロックされています。これを確認するには次のように入力します。

    $nmap -sS github.com -p 22
    Starting Nmap 5.35DC1 ( http://nmap.org ) at 2011-11-05 10:53 CET
    Nmap scan report for github.com (207.97.227.239)
    Host is up (0.10s latency).
    PORT   STATE    SERVICE
    22/tcp ***filtered*** ssh

    Nmap done: 1 IP address (1 host up) scanned in 2.63 seconds

ご覧のとおり、状態は Filtered です。これは、何かがブロックしていることを意味します。ポート 443 に SSH を実行することで、この問題を解決できます (ファイアウォール/ISP はこれをブロックしません)。また、github.com ではなく "ssh.github.com" に SSH する必要があることも重要です。そうしないと、SSH サーバーではなく Web サーバーにレポートすることになります。以下は、この問題を解決するために必要なすべての手順です。

解決:

(まず、説明どおりにキーを生成したことを確認してください。http://help.github.com/win-set-up-git/

ファイル ~/.ssh/config を作成します (ssh config ファイルはユーザーディレクトリにあります。Windows ではおそらく%USERPROFILE%\.ssh\config

次のコードを貼り付けます。

    Host github.com
    User git
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443

ファイルを保存します。

通常どおり ssh を実行します。

$ssh -T github.com 
    $Enter passphrase for key '.......... (you can smile now :))

ユーザー名やポート番号を指定する必要がないことに注意してください。

おすすめ記事