Last active
September 20, 2024 18:22
-
-
Save bynil/2126e374db8495fe33de2cbc543149ae to your computer and use it in GitHub Desktop.
Use git over socks5 proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Port: 1080 | |
1. Create a file /YOUR PATH/gitproxy.sh with content: | |
#!/bin/sh | |
nc -X 5 -x 127.0.0.1:1080 "$@" | |
2. Edit your ~/.gitconfig | |
# For git:// | |
[core] | |
gitproxy=/YOUR PATH/gitproxy.sh | |
# For http(s):// | |
[http] | |
proxy=socks5://127.0.0.1:1080 | |
[https] | |
proxy=socks5://127.0.0.1:1080 | |
3. Edit your /etc/ssh/ssh_config to change global setting (or ~/.ssh/config for special host) | |
# For ssh:// | |
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p |
Here's a short way to do this:
export GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -X 5 -x 127.0.0.1:1080 %h %p"' git ...
It works!
sorry to ask question here. But, what's the point of setting ssh config with proxycommand when you already create a proxy with nc?
sorry to ask question here. But, what's the point of setting ssh config with proxycommand when you already create a proxy with nc?
When you use nc
or connect
command, a tunnel is established to proxy the network traffic. But without setting ProxyCommand
, SSH is not aware of this tunnel. You have to explicitly tell it to use this tunnel for data transmission.
@yuanalexwu yyds
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error appear /
Have already downloaded socks5 list as socks5.txt