问题描述
我知道类似的问题已被多次提出。但我能找到的所有答案都是关于如何为http或ssh协议设置代理。这是情况。出于某种原因,gitious我需要克隆的git存储库不允许http或ssh。当我使用git clone ....我得到了... /没有找到ref:你在服务器上运行git update-server-info?错误。如果我使用git clone ssh://[email protected] / ...,我得到致命的:远程端意外挂起错误。 (可能我应该责怪android这个repo,因为我可以直接做git clone,但不能通过repo sync)。 (上面的测试都是在没有防火墙的情况下完成的。)所以我的问题是如何设置SSH隧道来在防火墙后面使用git协议。具体来说,我需要在防火墙后面执行git clone git://gitorious.org / ...(不是ssh://,不是http://)。
Thanks!
git:// 协议在端口9418上运行(记录在 git-daemon 手册页中,或运行 git daemon --help )。要通过SSH隧道转发,请执行以下操作:
ssh -L 9418:gitorious.org:9418您的.remote.host
连接之后,您可以像这样克隆远程存储库:
git clone git://localhost/path/to/repository.git
为了达到这个目的,你显然需要防火墙外的机器作为ssh命令的目标。
I know similar questions have been asked many times. But all I can find are answers about how to setup proxy for http or ssh protocols. Here is the situation. For some reason, the git repository on gitorious I need to clone doesn't allow http or ssh. When I use "git clone http://gitorious.org/...." I got ".../refs not found: did you run git update-server-info on the server?" error. If I use "git clone ssh://[email protected]/...", I got "fatal: The remote end hung up unexpectedly" error. (probably I should blame android "repo" for this one, because I can do git clone directly, but not through "repo sync"). (The above tests are all done without firewall.)
So my question is how to setup SSH tunnel to use git protocol behind a firewall. Specifically, I need to do "git clone git://gitorious.org/..." (not ssh://, not http://) behind firewall.Thanks!
The git:// protocol operates on port 9418 (documented in the git-daemon man page, or run git daemon --help). To forward this via an SSH tunnel, you would do something like this:
ssh -L 9418:gitorious.org:9418 your.remote.host
Once connected, you would clone a remote repository like this:
git clone git://localhost/path/to/repository.git
In order for this to work you obviously need a machine outside your firewall to be the target of the ssh command.
这篇关于如何使用SSH隧道来转发git协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!