You must use git behind the firewall: attempting ssh tunneling

I am trying to use ssh port forwarding to defeat a corporate firewall:

ssh git@GIT _SERVER -L9418:GIT_SERVER:9418 

and in another terminal I run

 git clone git://localhost:repositories/project.git 

But I get the following error:

Initialized Empty Git Repository at /Users/aboxer/tmp/glucosia/.git/

fatal: unable to find local host (port repositories) (nodename or servname provided or unknown)

Thanks!

+6
git ssh portforwarding tunnel
source share
4 answers

I am sure your problem (or at least one of them is causing this particular error):

 git clone git://localhost:repositories/project.git 

If you look at the list of URL notations in man git click, you will see the corresponding example:

 git://host.xz[:port]/path/to/repo.git/ 

In colon, you use "repositories" as the port name, and git (understandably) cannot connect to the port repositories on the local host! What are you looking for:

 git://localhost/path/to/repositories/project.git 

or maybe

 git://localhost/~user/repositories/project.git 

Edit:

I probably should have said this from the very beginning, but I can't think of the reason why you would need to use SSH tunneling with git. Its default transport protocol is ssh; the git protocol is really present only so that public repositories can be retrieved due to the lack of an account. If you can use SSH in the machine where the repository is located, you can simply get through ssh:

 git clone ssh://[ user@ ]host.xz/path/to/repo.git git clone ssh://[ user@ ]host.xz/~/path/to/repo.git git clone ssh://[ user@ ]host.xz/~user/path/to/repo.git 
+6
source share
+6
source share

Short version of Vlad Zlotan:

Configure the tunnel:

 ssh ServerWithSSHAccessAddress -L 2000:GitServerAddress:22 -N , & 

Clone repo

 git clone ssh:// user@localhost :2000/my_repo.git 
0
source share

Here are the steps that worked for me. My system is located behind the companyโ€™s firewall, and the domain joins it:

  • You must install the first npm
  • Fiddler should also work in run mode. Fiddler must work with the Authentication option in the Enabled Rules section
  • Install Git with the command:

npm install git

  • Update protocol from Git to https:

git config --global url. https://github.com/.insteadOf git: //github.com/

0
source share

All Articles