【问题标题】:Git SSH Error Bad File NumberGit SSH错误错误文件号
【发布时间】:2014-12-18 23:43:42
【问题描述】:

我正在设置一个带有 git 指南的 git 服务器 (http://git-scm.com/book/en/v2)。 所以我在 Ubuntu 服务器上创建了一个用户 git,我把我电脑的 ssh 密钥放在了authorized_keys 文件中。

我在 /repos/test/test.git 的 git 帐户上做了一个 repo 当我尝试使用

从 windows pc 克隆时
git clone git@196.168.0.114:/repos/test/test.git

它给了我这个:

Cloning into 'test'...
ssh: connect to host 196.168.0.114 port 22: Bad file number
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我的 git 账户也有密码

.ssh chmod 700 by git 帐号

git 账户的authorized_keys chmod 600

【问题讨论】:

  • 文件夹.ssh在服务器上的权限是什么? authorized_keys文件的权限是什么?
  • .ssh 在服务器上是 chmod 700,授权密钥是 chmod 600。我用 git 帐户做了 chmods

标签: git ssh


【解决方案1】:

来自GitHub documentation

此错误通常表示您无法连接到服务器。这通常是由防火墙和代理服务器引起的。

请检查您在 Windows 和 Linux 客户端上的防火墙设置。

试试ssh -vvv git@196.168.0.114

如果你在输出中看到这个:

 [196.168.0.114] port 22. debug1: connect to address 196.168.0.114 port 22: Attempt to connect timed out without establishing a connection

那么在你的两台计算机内部或之间有一个防火墙可以吞下数据包。

【讨论】:

  • 我关闭了windows和ubuntu服务器上的防火墙(在ubuntu上是这样的:$ sudo iptables -X $ sudo iptables -t nat -F $ sudo iptables -t nat -X $ sudo iptables -t mangle -F $ sudo iptables -t mangle -X $ sudo iptables -P INPUT ACCEPT $ sudo iptables -P FORWARD ACCEPT $ sudo iptables -P OUTPUT ACCEPT) 它仍然给出同样的错误
  • 尝试ssh -v -v -v git@196.168.0.114 并在输出中查找问题。
  • ssh -v -v -v git@196.168.0.114 OpenSSH_6.6.1,OpenSSL 1.0.1i 2014 年 8 月 6 日调试 1:读取配置数据 /etc/ssh/ssh_config 调试1:/etc/ssh/ssh_config第 1 行:为 * debug2 应用选项:ssh_connect:needpriv 0 debug1:连接到 196.168.0.114 [196.168.0.114] 端口 22。 debug1:连接到地址 196.168.0.114 端口 22:尝试连接超时而未建立连接 ssh:连接到主机 196.168.0.114 端口 22:错误文件号
  • 连接超时 -> 防火墙问题。您和 192.168.0.114 之间必须有另一个防火墙。你能ping通服务器吗?
  • 可以,平均 ping 为 2 毫秒
猜你喜欢
  • 2011-10-31
  • 1970-01-01
  • 2011-11-15
  • 2013-11-17
  • 1970-01-01
  • 2017-09-29
  • 2011-03-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多