需要在防火墙后面使用 git:尝试 ssh 隧道

发布于 2024-08-26 10:53:30 字数 357 浏览 10 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

别把无礼当个性 2024-09-02 10:53:31

我很确定您的问题(或者至少是导致此特定错误的问题)就在这里:

git clone git://localhost:repositories/project.git

如果您查看 url 符号列表 在 man git push 中,您将看到相关示例:

git://host.xz[:port]/path/to/repo.git/

使用冒号,您将使用“repositories”作为端口名称,并且 git (可以理解)无法连接到本地主机上的端口存储库!你正在寻找的是:

git://localhost/path/to/repositories/project.git

或者

git://localhost/~user/repositories/project.git

编辑:

我可能应该从一开始就这么说,但我实际上想不出你需要将 SSH 隧道与 git 一起使用的原因。它的默认传输协议是ssh; git 协议实际上只是允许在没有帐户的情况下获取公共存储库。如果您可以通过 SSH 连接到存储库所在的计算机,则可以通过 ssh 获取:

git clone ssh://[user@]host.xz/path/to/repo.git
git clone ssh://[user@]host.xz/~/path/to/repo.git
git clone ssh://[user@]host.xz/~user/path/to/repo.git

I'm pretty sure your problem (or at least the one causing this particular error) is here:

git clone git://localhost:repositories/project.git

If you look at the list of url notations in man git push you'll see the relevant example:

git://host.xz[:port]/path/to/repo.git/

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:

git://localhost/path/to/repositories/project.git

or perhaps

git://localhost/~user/repositories/project.git

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:

git clone ssh://[user@]host.xz/path/to/repo.git
git clone ssh://[user@]host.xz/~/path/to/repo.git
git clone ssh://[user@]host.xz/~user/path/to/repo.git
盗心人 2024-09-02 10:53:31

Vlad Zloteanu 答案的简短版本:

设置隧道:

ssh ServerWithSSHAccessAddress -L 2000:GitServerAddress:22 -N , &

克隆存储库

git clone ssh://user@localhost:2000/my_repo.git

The short version of Vlad Zloteanu's answer:

Set up the tunnel:

ssh ServerWithSSHAccessAddress -L 2000:GitServerAddress:22 -N , &

Clone the repo

git clone ssh://user@localhost:2000/my_repo.git
浅听莫相离 2024-09-02 10:53:31

以下是对我有用的步骤。我的系统位于公司防火墙后面,并且已加入域:

  • 首先需要安装 npm
  • Fiddler 也需要处于运行模式。 Fiddler 需要在“规则”下启用“自动验证”选项运行
  • 通过命令安装 Git:

npm install git

  • 将协议从 git 更新为 https:

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:

  • First npm needs to be installed
  • Fiddler needs to be in running mode as well. Fiddler needs to be running with ‘Automatically Authenticate’ option under ‘Rules’ enabled
  • Install Git via command:

npm install git

  • Update protocol from git to https:

git config --global url.https://github.com/.insteadOf git://github.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文