如何使用SSH隧道来转发git协议?

编程入门 行业动态 更新时间:2024-10-16 02:31:43
本文介绍了如何使用SSH隧道来转发git协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我知道类似的问题已被多次提出。但我能找到的所有答案都是关于如何为http或ssh协议设置代理。这是情况。出于某种原因,gitious我需要克隆的git存储库不允许http或ssh。当我使用git clone gitorious/ ....我得到了... /没有找到ref:你在服务器上运行git update-server-info?错误。如果我使用git clone ssh://git@gitorious / ...,我得到致命的:远程端意外挂起错误。 (可能我应该责怪android这个repo,因为我可以直接做git clone,但不能通过repo sync)。 (上面的测试都是在没有防火墙的情况下完成的。)

所以我的问题是如何设置SSH隧道来在防火墙后面使用git协议。具体来说,我需要在防火墙后面执行git clone git://gitorious / ...(不是ssh://,不是http://)。 Thanks!

解决方案

git:// 协议在端口9418上运行(记录在 git-daemon 手册页中,或运行 git daemon --help )。要通过SSH隧道转发,请执行以下操作:

ssh -L 9418:gitorious: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 gitorious/...." I got ".../refs not found: did you run git update-server-info on the server?" error. If I use "git clone ssh://git@gitorious/...", 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/..." (not ssh://, not ) 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: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协议?

本文发布于:2023-10-07 13:10:38,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   隧道   协议   SSH   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!