我正在尝试为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.
Run Code Online (Sandbox Code Playgroud)
但是,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.
Run Code Online (Sandbox Code Playgroud)
所以,我正在使用端口443,根据bitbucket文档:
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.
Run Code Online (Sandbox Code Playgroud)
我试过谷歌搜索"bitbucket ssh_exchange_identification:读取:连接重置由同行",但它没有帮助: - /然后我尝试调试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
Run Code Online (Sandbox Code Playgroud)
所以,SSH找到了正确的身份文件(/u/.ssh/bitbucketnek),然后就死了.现在,如果我能够弄清楚问题是否在我的"bitbucketnek"私钥中,或者是我们公司防火墙中的问题,还是第三种问题,那将会非常有用.有任何想法吗?
谢谢!
Edu*_*nda 12
作为一个有用的注释,我在共享托管环境,特别是GoDaddy,以及它给我这个错误的原因:
ssh_exchange_identification: read: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)
解决方案:我的本地计算机的IP已被GoDaddy阻止,所以我不得不联系他们的支持,向他们发送运行错误输出的屏幕截图:
ssh -v user @ domain
,并为他们提供我的IP.他们注意到我的ip实际上已被阻止,删除它,问题解决了.
Ken*_*ter 11
ssh_exchange_identification: read: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)
"通过对等方重置连接"表示TCP连接从远程(服务器)端"异常关闭"."ssh_exchange_identification"表示它在客户端和服务器交换软件版本字符串的阶段发生.这发生在客户端和服务器交换主机密钥或尝试进行身份验证之前.换句话说,在进行任何类型的密钥交换或认证之前,连接的远程端正在丢弃.
异常关闭(连接重置)通常表示服务器进程退出而未关闭连接,或者崩溃,或者防火墙或负载平衡器等因素干扰了连接.通常我建议在服务器上对此进行故障排除.但鉴于这是bitbucket,从假设他们的服务器正常工作开始可能是安全的.可能的替代方案是您的流量通过状态防火墙,负载均衡器或网络中的类似设备,并且由于某种原因迫使TCP流关闭.
我看到你正在尝试在端口443上运行SSH,可能遵循这些说明.也许您的网络工程师已阻止端口22到Internet?也许他们也在端口443上进行数据包检查,并且它们阻止了看起来不像HTTPS(HTTP over SSL)的流量.