我按照git指南但在尝试连接到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
Run Code Online (Sandbox Code Playgroud)
这是我在.ssh下的配置文件
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile "C:\Documents and Settings\mugues\.ssh\id_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
任何的想法?
Sam*_*Sam 186
在遇到这个问题后,我找到了一个可行的解决方案.
错误信息:
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
Run Code Online (Sandbox Code Playgroud)
在Windows上使用MINGGW shell时,您只会看到错误的文件编号消息.Linux用户只会获得Timed.
问题:
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
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,状态是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
将以下代码粘贴到其中:
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
Run Code Online (Sandbox Code Playgroud)
保存文件.
像往常一样执行ssh:
$ssh -T github.com
$Enter passphrase for key '.......... (you can smile now :))
Run Code Online (Sandbox Code Playgroud)
请注意,我不必提供用户名和端口号.
Sté*_*hon 40
关键信息是用@ Sam的答案写的,但不是很显着,所以让我们说清楚.
甚至没有-v
开关出现的线:
ssh: connect to host (some host or IP address) port 22: Bad file number
Run Code Online (Sandbox Code Playgroud)
实际上是无关紧要的.
如果你专注于它,你会浪费你的时间,因为它不是一个关于实际问题的暗示,只是在Windows上运行git的ssh的效果.它甚至不是git或ssh安装或配置错误的标志.真的,忽略它.
在Linux上使用相同的命令为我生成了这条消息,它提供了有关该问题的实际提示:
ssh: connect to host (some host or IP address) port 22: Connection timed out
Run Code Online (Sandbox Code Playgroud)
专注于-v
在命令行上添加的行.在我的情况下它是:
debug1: connect to address (some host or IP address) port 22: Attempt to connect timed out without establishing a connection
Run Code Online (Sandbox Code Playgroud)
我的问题是IP地址中的拼写错误,但您的问题可能有所不同.
如果有人能够证明只有在实际原因是"连接超时"时才出现"坏文件编号",那么解决连接可能会超时的原因是有意义的.
在此之前,"错误的文件编号"只是一般错误消息,并且通过说"忽略它并查找其他错误消息"来完全回答这个问题.
编辑:Qwertie提到错误消息确实是通用的,因为它也可能发生在"连接拒绝"上.这证实了分析.
请不要将这个问题与一般提示和答案混为一谈,它们与此问题的实际主题(和标题)无关,即"Git SSH错误:"连接到主机:错误的文件号"".如果使用-v
你有更多信息性的消息,值得他们自己的问题,然后打开另一个问题,然后你可以建立一个链接.
您还可以尝试:
telnet example.com 22
Run Code Online (Sandbox Code Playgroud)
查看您是否连接到服务器.我看到了这条消息,最终我正在阻止访问的VPN.脱离VPN,我很高兴.
归档时间: |
|
查看次数: |
176951 次 |
最近记录: |