Reputation: 305
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 [email protected]: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?
Upvotes: 2
Views: 5840
Reputation: 180
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
Upvotes: 2
Reputation: 321
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
Upvotes: 0