通过反向隧道克隆Git [英] Git clone through a reverse tunnel

查看:90
本文介绍了通过反向隧道克隆Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器上有我的Git回购,它在家里没有自己的公有知识产权,我想在我的Web服务器上克隆这个回购。反向隧道是否允许我从机器上拉到服务器是否正确?我要执行哪些命令来执行克隆?我的本地机器运行Windows;服务器运行Ubuntu。

解决方案

原则上,您可以执行类似于

  ssh -R 2222:localhost:22 username@webserver.com 

然后在你的web服务器上使用

  git clone ssh:// user @ localhost:2222 / path / to /但是,这会加密你的数据两次。



另外,你也可以使用git支持的任何其他协议,并为这些协议转发正确的端口。

你也可以把一段像这样进入〜/ .ssh / config:

  Host my-server 
HostName localhost
ForwardX11 no
Port 2222

然后你可以使用这个clone命令:
git clone git @ my-server:mytools / projectName.git 。 (这使您可以将服务器密钥存储为不属于 localhost ,并使您的git配置中的URL更加清晰。)



对于您的服务器(隧道服务器和最终主机),您通常需要根据公钥授权进行身份验证,因此您应该将私钥(例如id_rsa)放入您的〜/ .ssh目录中。 (这里的所有文件,特别是私钥,应该只对用户可读,并且该目录只能写入您的用户。)

所有这些都不是特定于隧道,而是通用SSH的东西。

I have my Git repo on my machine, which has no public IP of its own, at home; I want to clone this repo at my web server. Is it correct that a reverse tunnel will allow me to pull from my machine to the server? What command(s) do I issue to perform the clone? My local machine runs Windows; the server runs Ubuntu.

解决方案

In principle, you can do something like

ssh -R 2222:localhost:22  username@webserver.com 

and then use on your webserver

git clone ssh://user@localhost:2222/path/to/repo.git/

This will encrypt your data twice, though.

Alternatively, you can use any of the other protocols which git supports, and forward the right ports for these.

You can also put a section like this into ~/.ssh/config:

Host my-server
HostName localhost
ForwardX11 no
Port 2222

Then you can use this clone command: git clone git@my-server:mytools/projectName.git. (This allows you to store the server's key not as belonging to localhost, and makes the URL in your git config clearer.)

For your server (both the tunnel server and the final host) you usually want to authenticate per public-key authorization, for this you should put the private key (e.g. id_rsa) in your ~/.ssh directory. (And all files there, specifically the private key, should be readable only for your user, and the directory writable only for your user.)
All this is not specific for the tunnel, but generic SSH stuff.

这篇关于通过反向隧道克隆Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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