Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clone through a reverse tunnel

Tags:

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.

like image 222
Brian Avatar asked Jun 08 '11 19:06

Brian


People also ask

What is reverse Tunnelling?

Reverse tunneling is a tunneling from mobile host to home agent, and makes it possible for the mobile host from foreign network to communication in the network whose router has access filters.

How does reverse SSH tunnel work?

Reverse SSH solves this issue by simulating an SSH to the remote server. In this case, the remote machine listens on the local computer's network port. It relays SSH connection requests to that port back to itself, which establishes a new connection between the local and remote computers.


1 Answers

In principle, you can do something like

ssh -R 2222:localhost:22  [email protected]  

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.

like image 104
Paŭlo Ebermann Avatar answered Nov 13 '22 06:11

Paŭlo Ebermann