Home:ALL Converter>Accessing a git repository via ssh behind a firewall

Accessing a git repository via ssh behind a firewall

Ask Time:2009-11-13T20:29:36         Author:pajato0

Json Formatter

I would like to access (clone/push/pull) a private (via ssh) git repository while behind a corporate firewall that only allows http proxy access. I have written a robust Java (daemon) program (based on the JSCh class library) that will allow me to leverage local and remote port forwarding and I am hoping to leverage this but my brain hurts when I try to envision how to set this up.

The git repo depot (to coin a phrase) is at foo.server.com/var/git so the natural inclination, ignoring the fireall, to set up a clone would be:

$ git clone ssh://foo.server.com/var/git/myrepo.git

but the firewall will block this command. I'm inclined to try something like

$ git clone ssh://localhost:8022/var/git/myrepo.git

where localhost:8022 is forwarded to foo.server.com:22

So is this path worth pursuing? Is there any easier solution that is still secure? Are there pitfalls or gotchas I should be aware of?

Author:pajato0,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1728934/accessing-a-git-repository-via-ssh-behind-a-firewall
Gregor Beck :

Using socat and a .ssh/config like this:\n\nHost=foo.server.com\nProxyCommand=socat - PROXY:your.proxy.ip:%h:%p,proxyport=3128,proxyauth=user:pwd\n\n\nYou should be able to ssh to foo.server.com and\n\ngit clone ssh://foo.server.com/var/git/myrepo.git\n\n\nis expected to work.",
2011-11-24T10:14:57
Thilo :

Can you get a normal ssh (command-line) session going? If so, git should also work.\n\nWhen using ssh, git should pick up your configuration options in .ssh/config.\nIf that is not enough, you can point the environment variable GIT_SSH at a modified version of ssh (or shell script wrapper).",
2009-11-13T12:35:00
INS :

This is my setup working under a Linux machine (localhost on port 18081 is a proxy).\ncat ~/.ssh/config\nHost github.com\n User git\n ProxyCommand nc -x localhost:18081 -Xconnect %h %p\n",
2020-07-08T16:43:18
yy