note/tech/set_proxy_ssh.md
2025-11-19 10:16:05 +08:00

26 lines
569 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 给ssh设置代理
1. 编辑 `~/.ssh/config` 文件,添加以下内容:
```
Host github.com
Hostname github.com
User git
Port 22
ProxyCommand nc -X connect -x 127.0.0.1:1080 %h %p
```
这里的nc是使用的BSD nc如果是gnu nc则不行。如archlinux。需要安装 socat
```
sudo pacman -S socat
```
最后一行需要改为:
```
ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1080
```
ProxyCommand socat - SOCKS5:127.0.0.1:%h:%p,socksport=1080
```