2

I encountered a problem about Git on GitHub on my Ubuntu installation.

I have configured a proxy setting by git config --global http.proxy proxyserver:port.

But when I type git clone git@github.com:myusername/example.git, I get the following:

Error:

ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

What should I do?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
FlurryWInd
  • 305
  • 1
  • 4
  • 12
  • 2
    You're attempting to connect with `ssh`, which does not use the HTTP proxy settings. You may need to use an HTTP or HTTPS URL on Github. – Greg Hewgill Sep 04 '13 at 03:37
  • Maybe [this](http://stackoverflow.com/questions/1728934/accessing-a-git-repository-via-ssh-behind-a-firewall) can help it. – dyng Sep 04 '13 at 07:31
  • I use the https url to clone the repo, and it work. – FlurryWInd Sep 04 '13 at 13:18

2 Answers2

1

I follow the steps below to access git respositories from behind a corporate proxy. This method works for git repositories using git URLs like "git://something.git"; for git repositories using http URLs like "http://something.git" use the accepted answer for this link instead.

This version uses corkscrew and sets a username and password required by the proxy.

Install corkscrew (Ubuntu)

sudo apt-get install corkscrew

Create credentials file containing your proxy username and password

echo "username:password" > ~/.corkscrew-auth

In my case the credentials look like this

domain\username:password

Secure auth file

chmod 600 ~/.corkscrew-auth

Create corkscrew wrapper script ~/scripts/corkscrew.wrapper

#!/bin/sh
exec corkscrew PROXY_IP_ADDRESS PROXY_PORT $* ~/.corkscrew-auth

Make the script executable

chmod +x ~/scripts/corkscrew.wrapper

Configure git

git config --global core.gitproxy ~/scripts/corkscrew.wrapper

Test if you can clone a repository

git init
git clone git://SOME_GIT_REPOSITORY_ADDRESS

In case you want to clean the git configuration you just made

git config --global --unset core.gitproxy
Community
  • 1
  • 1
Robert
  • 171
  • 9
0

Step 1 : Install corkscrew

$ sudo apt-get install corkscrew

Step 2 : Write a script named git-proxy.sh and add the following

#!/bin/sh

exec corkscrew <name of proxy server> <port> $*

# <name_of_proxy_server> and <port> are the ip address and port of the server
# e.g. exec corkscrew 192.168.0.1 808 $*

Step 3 : Make the script executable

$ chmod +x git-proxy.sh

Step 4 : Set up the proxy command for GIT by setting the environment variable

$ export GIT_PROXY_COMMAND="/<path>/git-proxy.sh"

Now use the git commands,such as

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Sk Hasanujjaman
  • 321
  • 2
  • 2
  • could you please help me with - http://stackoverflow.com/questions/21600830/ssh-ing-to-remote-server-from-behind-a-proxy – whatf Feb 06 '14 at 10:57