【问题标题】:bibucket ssh_exchange_identification: read: Connection reset by peerbitbucket ssh_exchange_identification:读取:对等方重置连接
【发布时间】:2021-10-01 03:17:42
【问题描述】:

我正在尝试设置与 bitbucket 的无密码 git 连接。我在 Windows Server 2008 上使用 git bash。

通过 HTTPS 克隆工作正常:

nskoric@P8-DEV /z/test
$ git clone https://dijxtra@bitbucket.org/nek-plan/gittest.git
Cloning into 'gittest'...
Password for 'https://dijxtra@bitbucket.org':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

但是,HTTPS 是不可接受的,因为我需要无密码登录。所以我生成了一个私钥/公钥对,将公钥上传到 bitbucket 并在 .ssh/config 中设置 Host/IdentitiyFile。然后我尝试连接,但失败了。

我公司防火墙上的 22 端口已关闭:

nskoric@P8-DEV /z/test
$ ssh git@bitbucket.org -vv
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /u/.ssh/config
debug1: /u/.ssh/config line 1: Applying options for *bitbucket.org
debug2: ssh_connect: needpriv 0
debug1: Connecting to bitbucket.org [131.103.20.168] port 22.

所以,根据 bitbucket 文档,我使用的是端口 443:

nskoric@P8-DEV /z/test
$ git clone ssh://git@altssh.bitbucket.org:443/nek-plan/gittest.git
Cloning into 'gittest'...
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

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

我尝试使用谷歌搜索“bitbucket ssh_exchange_identification: read: Connection reset by peer”,但没有帮助:-/ 然后我尝试调试 SSH 连接,但这是我得到的最远的:

nskoric@P8-DEV /z/test
$ ssh git@altssh.bitbucket.org -p 443 -vv
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /u/.ssh/config
debug1: /u/.ssh/config line 1: Applying options for *bitbucket.org
debug2: ssh_connect: needpriv 0
debug1: Connecting to altssh.bitbucket.org [131.103.20.174] port 443.
debug1: Connection established.
debug1: identity file /u/.ssh/bitbucketnek type 1
debug1: identity file /u/.ssh/bitbucketnek-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
ssh_exchange_identification: read: Connection reset by peer

所以,SSH 找到了正确的身份文件 (/u/.ssh/bitbucketnek) 然后死了。现在,如果我能确定问题出在我的“bitbucketnek”私钥中,还是我们公司防火墙中的问题,或者第三个问题,那将非常有帮助。有什么想法吗?

谢谢!

【问题讨论】:

    标签: git ssh bitbucket


    【解决方案1】:
    kex_exchange_identification: read: Connection reset by peer
    or
    ssh_exchange_identification: read: Connection reset by peer
    

    “Connection reset by peer”表示 TCP 连接从远程(服务器)端“异常关闭”。 “ssh_exchange_identification”意味着它发生在客户端和服务器交换软件版本字符串的阶段。这发生在客户端和服务器交换主机密钥或尝试进行身份验证之前。换句话说,连接的远程端在任何类型的密钥交换或身份验证发生之前就断开了。

    (现代 OpenSSH 发出“kex_exchange_identification...”表单。旧版本的 OpenSSH 发出“ssh_exchange_identification...”表单。)

    异常关闭(连接重置)通常表示服务器进程在未关闭连接的情况下退出,或者它崩溃了,或者防火墙或负载平衡器之类的东西正在干扰连接。通常我建议在服务器上解决这个问题。但鉴于这是 bitbucket,从假设他们的服务器正常工作开始可能是安全的。可能的替代方案是您的流量正在通过有状态防火墙、负载平衡器或网络中的类似设备,并且由于某种原因它迫使 TCP 流关闭。

    我看到您正在尝试在端口 443 上运行 SSH,可能是在 these instructions 之后。也许您的网络工程师已经阻止了 Internet 的 22 端口?也许他们还在端口 443 上进行数据包检查,并且他们正在阻止看起来不像 HTTPS(基于 SSL 的 HTTP)的流量。

    【讨论】:

    • 是的,正如我在帖子中所说,我们的网络管理员一共屏蔽了 22 个。他们也在 443 上进行数据包检查是有道理的。我想避免打开蠕虫罐(要求网络管理员让步),但我显然必须这样做。如果问题与他们有关,将与我的管理员联系并接受您的回答。谢谢!
    • 从一个网络切换到另一个网络似乎实际上解决了这个问题。
    【解决方案2】:

    作为一个有用的注释,我在共享托管环境中遇到了这个案例,特别是 GoDaddy,以及它给我这个错误的原因:

    ssh_exchange_identification: read: Connection reset by peer
    

    解决方案:我的本地机器的 ip 被 GoDaddy 阻止了,所以我不得不联系他们的支持,将运行时错误输出的屏幕截图发送给他们:

    ssh -v 用户@域

    ,并为他们提供我的 ip。他们注意到我的 ip 实际上已被阻止,将其删除并解决了问题。

    【讨论】:

    • 这对我来说也是如此。共享主机和我的 IP 被阻止。谢谢。
    • @Eduardo 有没有其他方法可以解锁 IP ?
    • @KapilGarg 不在这种特殊情况下。为什么?
    • @EduardoLaHozMiranda 同样的事情发生在我身上,我听从了您的建议,致电支持中心。他们重置了设置,现在一切正常。谢谢芽
    【解决方案3】:

    当我尝试通过一个脚本,一个接一个地更新大约 20 个项目时,我已经看到了这种情况。我怀疑我遇到了某种限制。在每次拉动后添加“睡眠 10”似乎已经解决了问题。

    【讨论】:

      【解决方案4】:

      我可以使用通过 VPN 访问的 Atlassian Stash 服务器确认这一点,该服务器使用脚本“git pull”大量项目。对于他们中的许多人,我收到了“kex_exchange_identification: read: Connection reset by peer”错误,当在 pull 之间插入“sleep 5”时该错误消失了。

      【讨论】:

      • 这不能回答问题,最好作为对原始问题的评论。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多