跳至主要内容

错误:文件号错误

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

本文内容

运行远程 Git 命令或 SSH 时,连接可能会超时

$ ssh -vT git@github.com
> OpenSSH_8.1p1, LibreSSL 2.7.3
> 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

解决此问题

使用 HTTPS

通常,最简单的解决方案是完全避免使用 SSH。大多数防火墙和代理服务器都能毫无问题地允许 HTTPS 流量。要利用此方法,请更改您正在使用的 远程 URL

$ git clone https://github.com/USERNAME/REPO-NAME.git
> Cloning into 'reponame'...
> remote: Counting objects: 84, done.
> remote: Compressing objects: 100% (45/45), done.
> remote: Total 84 (delta 43), reused 78 (delta 37)
> Unpacking objects: 100% (84/84), done.

在其他网络上测试

如果您可以将计算机连接到没有防火墙的其他网络,您可以尝试测试到 GitHub 的 SSH 连接。如果一切正常,请联系您的网络管理员,帮助修改防火墙设置,以允许 SSH 连接成功。

使用 HTTPS 端口上的 SSH

如果无法使用 HTTPS,且防火墙管理员拒绝允许 SSH 连接,您可以尝试改用 HTTPS 端口上的 SSH

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.