I am trying to use ssh port forwarding to defeat 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 in /Users/aboxer/tmp/glucosia/.git/
fatal: Unable to look up localhost (port repositories) (nodename nor servname provided, or not known)
Thanks!
Cascabel :
I'm pretty sure your problem (or at least the one causing this particular error) is here:\n\ngit clone git://localhost:repositories/project.git\n\n\nIf you look at the list of url notations in man git push you'll see the relevant example:\n\ngit://host.xz[:port]/path/to/repo.git/\n\n\nWith the colon, you're using \"repositories\" as the port name, and git (understandably) has trouble connecting to port repositories on local host! What you're looking for is:\n\ngit://localhost/path/to/repositories/project.git\n\n\nor perhaps\n\ngit://localhost/~user/repositories/project.git\n\n\nEdit:\n\nI probably should've said this from the start, but I can't actually think of a reason you'd need to use SSH tunneling with git. Its default transport protocol is ssh; the git protocol is really only present to allow public repositories to be fetched from without an account. If you can SSH into the machine where the repository is located, you can just fetch via ssh:\n\ngit clone ssh://[user@]host.xz/path/to/repo.git\ngit clone ssh://[user@]host.xz/~/path/to/repo.git\ngit clone ssh://[user@]host.xz/~user/path/to/repo.git\n",
2010-03-28T14:37:22
Vlad Zloteanu :
I wrote a complete response/guide here: http://vladzloteanu.wordpress.com/2010/12/18/git-through-ssh-port-forwarding-ssh-tunneling/.",
2010-12-18T12:57:59
Pylinux :
The short version of Vlad Zloteanu's answer:\n\nSet up the tunnel:\n\nssh ServerWithSSHAccessAddress -L 2000:GitServerAddress:22 -N , &\n\n\nClone the repo\n\ngit clone ssh://user@localhost:2000/my_repo.git\n",
2013-11-06T09:30:33