通过防火墙后面的ssh访问git存储库 [英] Accessing a git repository via ssh behind a firewall

查看:207
本文介绍了通过防火墙后面的ssh访问git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问(克隆/推/拉)一个私人(通过ssh)git仓库,同时在一个只允许http代理访问的企业防火墙后面。我已经编写了一个强大的Java(守护进程)程序(基于JSCh类库),这将允许我利用本地和远程端口转发,并且我希望利用这一点,但是当我试图设想如何设置时, 。

git repo depot(输入一个短语)位于foo.server.com/var/git,所以忽略fireall的自然倾向设置克隆将是:

pre $ code $ git克隆ssh://foo.server.com/var/git/myrepo.git

但防火墙会阻止此命令。我倾向于尝试像

  $ git克隆ssh:// localhost:8022 / var / git / myrepo.git 

其中localhost:8022被转发到foo.server.com:22



那么这条道路值得追求吗?有没有更简单的解决方案仍然安全?是否有陷阱或陷阱我应该知道?

解决方案

你能得到正常的ssh(命令行)会话吗?如果是这样,git也应该可以工作。



使用ssh时,git应该选择.ssh / config中的配置选项。
如果这还不够,可以将环境变量GIT_SSH指向修改后的ssh版本(或shell脚本封装器)。


I would like to access (clone/push/pull) a private (via ssh) git repository while behind a corporate firewall that only allows http proxy access. I have written a robust Java (daemon) program (based on the JSCh class library) that will allow me to leverage local and remote port forwarding and I am hoping to leverage this but my brain hurts when I try to envision how to set this up.

The git repo depot (to coin a phrase) is at foo.server.com/var/git so the natural inclination, ignoring the fireall, to set up a clone would be:

$ git clone ssh://foo.server.com/var/git/myrepo.git

but the firewall will block this command. I'm inclined to try something like

$ git clone ssh://localhost:8022/var/git/myrepo.git

where localhost:8022 is forwarded to foo.server.com:22

So is this path worth pursuing? Is there any easier solution that is still secure? Are there pitfalls or gotchas I should be aware of?

解决方案

Can you get a normal ssh (command-line) session going? If so, git should also work.

When using ssh, git should pick up your configuration options in .ssh/config. If that is not enough, you can point the environment variable GIT_SSH at a modified version of ssh (or shell script wrapper).

这篇关于通过防火墙后面的ssh访问git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆