GIT is becoming very popular as SCM due to its simplicity and flexibity. Often software developers encounter proxy issue when the server sit behind firewall. There are three protocols git can use to clone a repository: http, git and ssh.

proxy setup](/uploads/git/git-proxy-setup.jpg)

GIT clone example:

  1. git clone
  2. git clone git://
  3. git clone ssh://

In this post, I explain how to set up proxy for each protocol using as example.


There are two approaches: env variable and git config

set http_proxy enviroment variable

weng@weng-ucs1:$ export http_proxy=''


git config

git config --global http.proxy

weng@weng-ucs1:$ cat ~/.gitconfig 
	proxy =

then it works as following:

git clone


First install corkscrew using apt-get (since I’m running ubuntu) sudo apt-get install corkscrew

Second, create a bash script named as “git-proxy”

weng@weng-ucs1:$ cat /usr/local/bin/git-proxy 

exec /usr/bin/corkscrew 8080 $* 
weng@weng-ucs1:$ git config  --global   core.gitProxy git-proxy

Finally, it works as following:

git clone git://


This is most complicated scenario. I use as example.

Step#1 create an entry in ~/.ssh/config like below:

weng@weng-ucs1:$ cat /home/weng/.ssh/config
  User git
  ProxyCommand nc -x %h %p

Step#2 Generate RSA key and add into Please take the steps from

weng@weng-ucs1:$ ssh-keygen -t rsa -C ""

weng@weng-ucs1:$ cat ~/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChKci3nRcHGZ5v1OspCiIX8vj72VCCksuILKjaFC5Q+u95AtWa1+kDhQj02ijA+RQGttWfEK5es7M9pfeeBHjtsuTSbbcReyKWi4qBIMKrGV6fyadeVad1Sj7GpV3eUUFZjjMTVgSZJ5lUK1JRpYjr2LuDD8etQgo7k0rwy3i/gIDlp2U4marG/0oPB2btLI/CgUcbBnNX/hsuR1P/hRX31HUp+Ru5UxypHNSuyh6YH6e0i2vfvbKcnU0xnk1ed7dBD86Np8uu76jfM5MdNe1AvPUx4+oJM0c6yf6e55sco5wLy8nTDgRftVW4wbbe93Y+zxwXU/AsW2HNakh0mR5L

Add above key into your account, after that, then we should see following:

weng@weng-ucs1:$ ssh
PTY allocation request failed on channel 0
Hi weweng! You've successfully authenticated, but GitHub does not provide shell access.
Connection to closed.

Now we can veirfy git over ssh work:

weng@weng-ucs1:$ git clone ssh://
Cloning into 'blog'...
remote: Counting objects: 157, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 157 (delta 6), reused 0 (delta 0), pack-reused 142
Receiving objects: 100% (157/157), 2.30 MiB | 1.17 MiB/s, done.
Resolving deltas: 100% (57/57), done.