> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# 解决 git 命令使用 SSH 时无法连接、没有使用代理的问题
- URL: https://sgpublic.xyz/p/2026/04/6aac9cb1810a480001533619/
- Published: 2026-04-25T05:12:35.000Z
- Updated: 2026-04-25T05:12:35.000Z
- Author: Haven Madray
- Tags: 网络与路由, Git, #wp-post

我自己的网络环境是透明代理，再不济自己电脑上也能开 TUN，所以 git 命令就算走 ssh，搭配如下配置让连接 GitHub 使用 443 端口，就能走 HTTP 代理：

```
Host github.com
  HostName ssh.github.com
  Port 443
  User git

```

但是在不可控的容器环境里无法使用 TUN 的情况下，无法完成透明代理，SSH 也就无法使用代理了。

解决方案如下：

在 `~/.ssh/config` 最前面添加以下配置：

```
Host *
 ProxyCommand nc -x <sock5代理> %h %p

```

其中 `<sock5代理>` 是你代理软件开放的 SOCK5 代理地址，例如 `127.0.0.1:1080`。

安装 `nc`：

```shell
  sudo apt install netcat-openbsd

```

改完即刻生效。</sock5代理></sock5代理>