The note is generated by ChatGPT.
Observation — Proxy set, but SSH still fails
Although you set http_proxy / https_proxy (or all_proxy), running:
| |
still times out or fails.
Root cause — SSH does NOT use the HTTP proxy (key point)
Terminal HTTP/SOCKS environment variables affect HTTP/HTTPS-aware programs (curl, wget, git clone https://…, etc.), but OpenSSH does not honor those variables. SSH opens a raw TCP connection and must be explicitly told to use a proxy — otherwise it tries a direct connection and gets blocked by the network/firewall.
Solution — force SSH through your proxy using ProxyCommand
Add the following to ~/.ssh/config (replace 127.0.0.1:7890 with your proxy host:port):
| |
Explanation: this tells SSH to use nc to proxy via a SOCKS5 server (-X 5) at 127.0.0.1:7890 to reach ssh.github.com:443. After this ssh -T git@github.com and git push over SSH should work.
Another solution — Switch SSH to HTTPS directly
In my experience, even using the last solution, network performance can be unreliable. Therefore, if you can use HTTPS for Git, I recommend switching from SSH to HTTPS directly. Please refer the article ‘Git配置PAT’