You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bitbucket克隆遇端口22超时/443格式无效,求解决方案

Bitbucket克隆超时及443端口连接错误的解决方案

问题背景

从Bitbucket克隆仓库时,端口22连接超时。尝试改用443端口,无论是通过配置文件还是直接在git clone命令中指定ssh://git@altssh.bitbucket.org:443/workspace/repo.git,都出现以下错误:

Cloning into 'homerunner'...
kex_exchange_identification: banner line contains invalid characters 
banner exchange: Connection to (port_number) port 443: invalid format
fatal: Could not read from remote repository.

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

执行GIT_SSH_COMMAND='ssh -v' git clone ssh://git@altssh.bitbucket.org:443/workspace/repo后,debug日志显示返回了HTTP 400错误页面:

Cloning into 'homerunner'...
OpenSSH_8.9p1 Ubuntu-3ubuntu0.3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data ~/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to altssh.bitbucket.org [18.205.93.15] port 443.
debug1: Connection established.
debug1: identity file ~/.ssh/id_rsa type 0
debug1: identity file ~/.ssh/id_rsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa type -1
debug1: identity file ~/.ssh/id_ecdsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa_sk type -1
debug1: identity file ~/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file ~/.ssh/id_ed25519 type 3
debug1: identity file ~/.ssh/id_ed25519-cert type -1
debug1: identity file ~/.ssh/id_ed25519_sk type -1
debug1: identity file ~/.ssh/id_ed25519_sk-cert type -1
debug1: identity file ~/.ssh/id_xmss type -1
debug1: identity file ~/.ssh/id_xmss-cert type -1
debug1: identity file ~/.ssh/id_dsa type -1
debug1: identity file ~/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.3
debug1: kex_exchange_identification: banner line 0: <HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD>
debug1: kex_exchange_identification: banner line 1: <BODY BGCOLOR="white" FGCOLOR="black"><H1>Invalid HTTP Request</H1><HR>
debug1: kex_exchange_identification: banner line 2: <FONT FACE="Helvetica,Arial"><B>
debug1: kex_exchange_identification: banner line 3: Description: Bad request syntax</B></FONT>
debug1: kex_exchange_identification: banner line 4: <HR>
debug1: kex_exchange_identification: banner line 5: <!-- default "Invalid HTTP Request" response (400) -->
debug1: kex_exchange_identification: banner line 6: </BODY>
kex_exchange_identification: banner line contains invalid characters
banner exchange: Connection to 18.205.93.15 port 443: invalid format
fatal: Could not read from remote repository.

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

解决方案

1. 排查网络代理/防火墙限制

从日志看,连接到altssh.bitbucket.org的443端口后返回了HTTP错误,说明你的SSH请求可能被代理或防火墙强制转换成了HTTP请求:

  • 关闭当前运行的代理工具,重新尝试克隆。
  • 联系网络管理员,确认是否有防火墙规则拦截SSH流量(即使是443端口),或强制将443端口流量转向HTTP协议。

2. 改用HTTPS协议克隆

放弃SSH协议,直接使用HTTPS链接克隆仓库:

git clone https://bitbucket.org/workspace/repo.git

如果已有本地仓库,可将远程地址切换为HTTPS:

git remote set-url origin https://bitbucket.org/workspace/repo.git

3. 修正SSH配置(坚持用SSH时)

确保~/.ssh/config配置正确指向Bitbucket的443端口SSH服务,配置内容如下:

Host altssh.bitbucket.org
  HostName altssh.bitbucket.org
  Port 443
  User git
  IdentityFile ~/.ssh/id_rsa  # 替换为你实际的私钥路径

保存配置后,使用简化命令克隆:

git clone git@altssh.bitbucket.org:workspace/repo.git

若配置后仍返回HTTP错误,说明网络环境无法支持443端口的SSH流量,只能改用HTTPS。

4. 验证Bitbucket SSH密钥配置

确认你的SSH公钥已正确添加到Bitbucket账户:

  • 登录Bitbucket,进入个人设置 → SSH密钥。
  • 检查是否存在当前使用的SSH公钥,若缺失则添加~/.ssh/id_rsa.pub(或对应密钥文件)的内容。

内容的提问来源于stack exchange,提问作者Yasir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 01:40:22