Skip to content

Instantly share code, notes, and snippets.

@ozbillwang
Last active August 23, 2025 04:37
Show Gist options
  • Save ozbillwang/005bd1dfc597a2f3a00148834ad3e551 to your computer and use it in GitHub Desktop.
Save ozbillwang/005bd1dfc597a2f3a00148834ad3e551 to your computer and use it in GitHub Desktop.
Configure Git to use a proxy (https or SSH+GIT)

There are several ways to clone a repository from github. Similar from other providers, such as bitbucket, gitlab, etc.

https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols

Mostly, we use

  • http
  • ssh

Sample clone commands:

The clone command with protocol https

git clone https://github.com/kubernetes/kubernetes.git

The clone command with protocol ssh+git

git clone [email protected]:kubernetes/kubernetes.git

Work with ssh config

When we are behind proxy, I have to set ssh config (~/.ssh/config) with ProxyCommand properly, git clone start working with proxy.

Install corkscrew or other proxy tool first.

with this way, we don't need provide username and password each time when clone the repository behind proxy

set ssh config

Host github.com
    Hostname github.com
    ServerAliveInterval 55
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p

need write down username and password for your proxy.

In some company policies, the password need be changed every 90 days, so you need update this configuration file when your proxy password is changed.

cat ~/.ssh/myauth
proxyUsername:proxyPassword

set ssh config

Host github.com
    Hostname github.com
    ServerAliveInterval 55
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p ~/.ssh/myauth

Work with http/https

update ~/.gitconfig

[http]
[http "https://github.com"]
	proxy = http://proxyUsername:[email protected]:port
	sslVerify = false

sslVerify setting is not necessary.

Notes:

If you only need access github by the way of ssh+git, you needn't set any proxy in ~/.gitconfig and run git config --global http.proxy ... and similar commands at all

@frittentheke
Copy link

But it works with nc command ProxyCommand nc -x 192.168.10.1:7070 %h %p

@flintt Corkscrew wants the host and port as two separate arguments, not host:post

@anquegi
Copy link

anquegi commented Sep 24, 2024

Thanks this realliy worken for my manjaro arch linux

@BensonleeHC
Copy link

Will this work on windows?

@ozbillwang
Copy link
Author

ozbillwang commented Aug 11, 2025

Will this work on windows?

you can install git for windows first, then run the terminal of git for bash

you can run many popular linux commands, include ssh, in windows directly

@BensonleeHC
Copy link

Will this work on windows?

you can install git for windows first, then run the terminate of git for bash

you can run many popular linux commands, include ssh, in windows directly

Appreciate, I will give a try with git bash on windows

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