Skip to content

Instantly share code, notes, and snippets.

@craftslab
Created February 19, 2026 06:20
Show Gist options
  • Select an option

  • Save craftslab/028d3fb77ae0e7155b4cb296ca32ab5b to your computer and use it in GitHub Desktop.

Select an option

Save craftslab/028d3fb77ae0e7155b4cb296ca32ab5b to your computer and use it in GitHub Desktop.
ssh tunneling

SSH Tunneling on Windows WSL2 for Both Web and Git

This guide uses one SSH SOCKS tunnel for both:

  • Browsing websites like https://github.com
  • Pushing Git over HTTPS, e.g. https://github.com/codex-router/codex.gerrit.git

1) Start SSH SOCKS tunnel in WSL2

Open WSL terminal and run:

ssh -N -D 7898 youruser@your-ssh-server

Keep this terminal open while browsing or running Git commands.

2) Use tunnel for website browsing (HTTP/HTTPS)

Configure browser proxy:

  • SOCKS Host: 127.0.0.1
  • Port: 7897
  • Type: SOCKS5
  • Enable remote DNS over SOCKS (important)

Then open sites normally, for example:

  • https://github.com
  • http://example.com

3) Use tunnel for Git over HTTPS

In your repository, set/check remote:

git remote set-url origin https://github.com/codex-router/codex.gerrit.git
git remote -v

Configure proxy for this repo (recommended):

git config http.proxy socks5h://127.0.0.1:7898
git config https.proxy socks5h://127.0.0.1:7898

Push:

git push origin main

When prompted for credentials:

  • Username: your GitHub username
  • Password: your GitHub Personal Access Token (PAT)

GitHub does not accept account password for Git over HTTPS.

4) One-time Git push without saving proxy

ALL_PROXY=socks5h://127.0.0.1:7898 git push origin main

5) Remove Git proxy config (optional)

git config --unset http.proxy
git config --unset https.proxy

6) Quick troubleshooting

  • Check tunnel is listening:
    ss -ltn | grep 7898
  • Verify remote URL:
    git remote -v
  • If auth fails, clear old cached credentials and retry using PAT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment