Skip to content

Instantly share code, notes, and snippets.

@pinei
Created May 4, 2022 14:22
Show Gist options
  • Select an option

  • Save pinei/d295e0dce30703d2e3c8b97df70345d6 to your computer and use it in GitHub Desktop.

Select an option

Save pinei/d295e0dce30703d2e3c8b97df70345d6 to your computer and use it in GitHub Desktop.
Git SSH over Proxy (Windows)

Create ~/.ssh/config (notepad %home%\.ssh\config)

ProxyCommand "C:\Program Files\Git\bin\connect.exe" -H <proxy-server>:<proxy-http-port> %h %p

Host 127.0.0.1
  HostName 127.0.0.1
  User <username>

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:\users\<username>\.ssh\id_rsa"
  TCPKeepAlive yes
  IdentitiesOnly yes

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile "C:\users\<username>\.ssh\id_rsa"
  TCPKeepAlive yes
  IdentitiesOnly yes

Msysgit includes connect.exe, so you do not need to download and compile connect. A precompiled exe is also available here.

Now ssh github.com should work

Note that if you want to connect via a socks5 proxy, then change -H to -S.

ProxyCommand connect -S <proxy-server>:<proxy-socket-port> %h %p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment