Git SSH错误:“连接到主机:错误的文件编号” [英] Git SSH error: "Connect to host: Bad file number"

查看:162
本文介绍了Git SSH错误:“连接到主机:错误的文件编号”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循 git指南,但尝试尝试时遇到这个奇怪的问题连接到github:

  $ ssh -v git@github.com 
OpenSSH_4.6p1,OpenSSL 0.9.8e 2007年2月23日
debug1:读取配置数据/ c / Documents and Settings / mugues / .ssh / config
debug1:为github.com申请选项
debug1:连接到github.com [207.97 .227.239]端口22.
debug1:连接到地址207.97.227.239端口22:尝试连接超时但未建立连接
ssh:连接到主机github.com端口22:错误的文件编号

这是我在.ssh下的配置文件

 主机github.com 
用户git
主机名github.com
PreferredAuthentications publickey
IdentityFileC:\Documents and Settings\mugues\\ \\.ssh\id_rsa
TCPKeepAlive yes
IdentitiesOnly yes

有什么想法?

解决方案



错误消息:

  ssh -v git@github.com 
OpenSSH_5.8p1,OpenSSL 1.0.0d 2011年2月8日
debug1:连接到github.com [207.97.227.239]端口22.
debug1:connect地址为207.97.227.239端口22:连接超时
ssh:连接到主机github.com端口22:连接超时
ssh:连接到主机github.com端口22:坏文件编号

只有在使用MINGGW shell的窗口中才会看到错误的文件编号消息。 Linux用户只会得到超时。



问题:

你可以通过键入

  $ nmap -sS github.com -p 22 
启动Nmap 5.35DC1(http://nmap.org)于2011-11-05 10:53 CET
github.com的Nmap扫描报告(207.97.227.239)
主机已启动(延迟为0.10s) 。
端口状态服务
22 / tcp ***过滤*** ssh

Nmap完成:1个IP地址(1个主机)在2.63秒内扫描

正如你所看到的,状态是Filtered,这意味着某些东西阻塞了它。
您可以通过执行SSH到端口443来解决此问题(您的防火墙/ isp不会阻止此操作)。
什么也是重要的,你需要ssh到ssh.github.com而不是github.com。
否则您将报告给网络服务器而不是ssh服务器。
解决此问题所需的所有步骤。

解决方案:

(首先,请确保您生成的密钥类似于 http://help.github.com / win-set-up-git /

创建文件〜/ .ssh / config(位于用户目录中的ssh配置文件)
在windows上可能%USERPROFILE%\.ssh\config



粘贴下面的代码:

 主机github.com 
用户git
主机名ssh.github.com
PreferredAuthentications publickey
IdentityFile〜/ .ssh / id_rsa
端口443

保存文件



像往常一样执行ssh:

  $ ssh -T github.com 
$输入关键字'..........'的密码(你现在可以微笑:))

请注意,我不必提供用户名和端口号。


I followed the git guide but I have this strange issue when trying to connect to github:

$ ssh -v git@github.com
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

This is my config file under .ssh

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

Any idea?

解决方案

After having this problem myself i found a working solution for me.

Error message:

    ssh -v git@github.com
    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

You will only see the bad file number message when on windows using the MINGGW shell. Linux users will just get Timed out.

Problem:

SSH is probably blocked on port 22. You can see this by typing

    $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

As you can see the state is Filtered, which means something is blocking it. You can solve this by performing an SSH to port 443 (your firewall / isp wont block this). Whats also important that you need to ssh to "ssh.github.com" instead of github.com. Else you will report to the webserver instead of ssh server. Below all the steps needed to solve this problem.

Solution:

(First of all make sure you generated your keys like explained on http://help.github.com/win-set-up-git/)

create file ~/.ssh/config (ssh config file located in your user directory. On windows probably %USERPROFILE%\.ssh\config

Paste the following code in it:

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

Save the file.

Perform ssh like usual:

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

Note that i dont have to supply the username nor port number.

这篇关于Git SSH错误:“连接到主机:错误的文件编号”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆