Skip to content

Instantly share code, notes, and snippets.

@sn0wcat
Last active January 25, 2024 23:50
Show Gist options
  • Save sn0wcat/cb8fa4b3b765a05630e8a45028f6b5f4 to your computer and use it in GitHub Desktop.
Save sn0wcat/cb8fa4b3b765a05630e8a45028f6b5f4 to your computer and use it in GitHub Desktop.
Using git / ssh through http proxy on windows

Using git / ssh through http proxy on windows

If you are moving your development machine from an unrestricted to a restricted network and back, the chances are high that you will have problems using ssh or git dependent on the network where your computer is currently set up.

A good way to circumvent this is to use a local development proxy (like fiddler) on your computer and to tunnel all connections through it.

For example I am running fiddler on my machine on port 8888 (accepting external connections) and I am using the following setup:

# in .bashrc of git for windows

export https_proxy=http://localhost:8888
export http_proxy=$https_proxy
export ftp_proxy=$https_proxy
export HTTPS_PROXY=$https_proxy
export HTTP_PROXY=$https_proxy
export FTP_PROXY=$https_proxy
export no_proxy={...list of my local addresses and domains...}
export NO_PROXY=$no_proxy

You also don't need extra tooling to configure git and ssh to use your proxy through a tunnel as git for windows comes with connect tool which can tunnel SSH connections through https.

in /etc/ssh/ssh_config of the git shell:

Host *
  ProxyCommand connect -H localhost:8888 %h %p
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

Host github.com
  user git
  Port 22
  Hostname github.com


Host gitlab.com
  user git
  Port 22
  Hostname gitlab.com
@henning-schild
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment