Opt-In Software Blog

Software, dvelopment, and practical insights

Using Git SSH Through a SOCKS5 Proxy on Windows

Read in: English | Русский

Sometimes git push or git fetch over SSH may fail due to network restrictions or DPI filtering. Using a VPN solves the problem, but routing all system traffic through a VPN is not always desirable.

If your network connection is affected by DPI filtering, you can route Git SSH connections through a SOCKS5 proxy that bypasses these restrictions. The proxy can be running locally or on a remote server. OpenSSH’s ProxyCommand feature makes it possible to use this proxy without routing all system traffic through a VPN.

Configuration

Git for Windows already includes a utility called connect.exe, located at:

C:\Program Files\Git\mingw64\bin\connect.exe

Open the SSH configuration file (%USERPROFILE%\.ssh\config) and add:

Host github.com
    ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -S 127.0.0.1:1080 %h %p

Here, github.com is just an example of an SSH server whose access is restricted. Replace it with the hostname you need. For example, it could be a Git server used by a particular project.

Replace 127.0.0.1:1080 with the address and port of your SOCKS5 proxy if necessary.

Note: On Windows, use forward slashes (/) in the executable path and specify the full path to connect.exe. Otherwise, OpenSSH may fail to locate the executable.

Testing

Test the SSH connection:

ssh -T git@github.com

Replace github.com with the hostname of your SSH server and git with your username.

If authentication succeeds, Git operations using SSH, including git push and git fetch, will use the SOCKS5 proxy.

This approach requires no system-wide VPN or changes to Windows network settings. Only SSH connections to the specified host are routed through the proxy.

Search