需要在防火墙后面使用 git:尝试 ssh 隧道
我正在尝试使用 ssh 端口转发来击败公司防火墙:
ssh git@GIT_SERVER -L9418:GIT_SERVER:9418
并在另一个终端中运行
git clone git://localhost:repositories/project.git
但出现以下错误:
在 /Users/aboxer/tmp/glucosia/.git/ 中初始化空 Git 存储库
致命:无法查找本地主机(端口存储库)(提供节点名或服务名,或未知)
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我很确定您的问题(或者至少是导致此特定错误的问题)就在这里:
如果您查看 url 符号列表 在 man git push 中,您将看到相关示例:
使用冒号,您将使用“repositories”作为端口名称,并且 git (可以理解)无法连接到本地主机上的端口存储库!你正在寻找的是:
或者
编辑:
我可能应该从一开始就这么说,但我实际上想不出你需要将 SSH 隧道与 git 一起使用的原因。它的默认传输协议是ssh; git 协议实际上只是允许在没有帐户的情况下获取公共存储库。如果您可以通过 SSH 连接到存储库所在的计算机,则可以通过 ssh 获取:
I'm pretty sure your problem (or at least the one causing this particular error) is here:
If you look at the list of url notations in man git push you'll see the relevant example:
With 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:
or perhaps
Edit:
I 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:
我在这里写了一个完整的回复/指南: http://vladzloteanu.wordpress.com/2010/12/18/git-through-ssh-port-forwarding-ssh-tunneling/。
I wrote a complete response/guide here: http://vladzloteanu.wordpress.com/2010/12/18/git-through-ssh-port-forwarding-ssh-tunneling/.
Vlad Zloteanu 答案的简短版本:
设置隧道:
克隆存储库
The short version of Vlad Zloteanu's answer:
Set up the tunnel:
Clone the repo
以下是对我有用的步骤。我的系统位于公司防火墙后面,并且已加入域:
npm install git
git config --global url。https://github.com/.insteadOf git://github.com/
Here are the steps that worked for me. My system is behind company firewall and it is domain joined:
npm install git
git config --global url.https://github.com/.insteadOf git://github.com/