git - 位桶 ssh_exchange_identification : read: Connection reset by peer

标签 git ssh bitbucket

我正在尝试设置到 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 是 Not Acceptable ,因为我需要无密码登录。所以我生成了一个私钥/公钥对,将公钥上传到 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”私钥中,还是出在我们公司的防火墙中,或者第三个问题,那将非常有帮助。有什么想法吗?

谢谢!

最佳答案

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”意味着它发生在客户端和服务器交换软件版本字符串的阶段。这发生在客户端和服务器交换主机 key 或尝试进行身份验证之前。换句话说,连接的远程端在任何类型的 key 交换或身份验证发生之前就断开了。

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

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

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

关于git - 位桶 ssh_exchange_identification : read: Connection reset by peer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27690101/

相关文章:

Git 告诉我 pull ,然后提交,然后 pull ?

linux - 通过 SSH 连接代理命令

java - 无法使用 JSch 和 JDK 8 打开 ssh session

git - 通过 ssh 进行两步 git 导入

git - 使用 Maven 发布插件将 ArtifactId 附加到 SCM Url

git - 无响应的 git 状态、差异、添加(挂起)

Git - 清理旧分支

git - 在单个 rebase 中将一大块提交移动到另一个提交

git - git 在哪里存储提交摘要和详细信息?

SSH 强制命令参数