我在代理下,我在相当长的一段时间内成功地推进。 现在我突然不能进入git了。 我已经设置了RSA密钥和代理,并仔细检查了它们,没有效果,git抛出了页面标题中显示的错误。


当前回答

我也遇到了同样的问题,但找不到有效的解决方案。我在设置本地服务器时遇到了这个问题,git无法通过我的代理网络连接,但我的工作站可以。这是我运行命令时的输出 ssh -vT git@github.com

ubuntu@server:~$ ssh -vT git@github.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/ubuntu/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [13.234.176.102] port 22.

因此,我尝试通过编辑配置文件~/使用通过HTTPS端口建立的SSH连接。Ssh /config但是没有效果。

Host github.com
 Hostname ssh.github.com
 Port 443

最后,我找到了这篇文章,解决并暴露了真正的问题。

# github.com
Host github.com
    Hostname ssh.github.com
    ProxyCommand nc -X connect -x <PROXY-HOST>:<PORT> %h %p
    Port 443
    ServerAliveInterval 20
    User git

这是我的配置文件,现在git通过ssh工作得很好!

其他回答

这个答案是基于@zundi对主要问题的评论(功劳应该归谁,谢谢zundi):

在您的移动设备上创建热点并连接热点 git推 关闭您的移动设备上的热点并重新连接到原来的网络 Git推送继续工作

我不知道为什么临时连接到一个热点神奇地“启动”原来的网络连接。

好试试这个ssh -T -p 443 git@ssh.github.com而不是ssh -T git@github.com

在.ssh文件夹中 创建config文件

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

基本URL重写

Git提供了一种使用Git配置重写url的方法。只需发出以下命令:

git config --global url."https://".insteadOf git://

现在,就像变魔术一样,所有git命令都将执行git://到https://的替换

来源: git://协议被公司阻止,我怎么能绕过它?

重启电脑帮我解决了这个问题。 Git版本:2.27.0.windows.1 操作系统版本:Windows 10