Search code examples
rubylanguage-agnosticsshtunnel

How does a service such as tunnlr work?


The website says:

Tunnlr uses SSH remote tunneling. It securely connects a port on your local machine to an open port on our public server. Once you start your Tunnlr client, the web server on your local machine will be available to the rest of the world through your special Tunnlr URL.

Could someone please go into a bit more detail over how this entire process works? Or maybe point to something open source that allows the same thing?


Solution

  • The SSH protocol allows tunneling of connections in either direction. So based on the description above here's what is happening:

    1. You download a client program (an SSH client) to your computer and run it.
    2. The client establishes an SSH connection out from your computer to the tunnlr remote server
    3. On the tunnlr server an access port is opened for incoming connections. Let's say port 1234.
    4. Now when anyone connects to tunnlr:1234 the tunnlr server will instruct your client program through the connection established in step 2 to open a connection inside your computer - let's say to port 80 (e.g. you're running a webserver there).
    5. The tunnel connection will now shuffle data between tunnlr:1234 and your_computer:80.

    So effectively this is what is running:

    [some_remote_computer]<->[tunnlr:1234]<->[SSH tunnel]<->[your_computer:80]
    

    Assume some_remote_computer is your friend or anyone else you want to be able to connect to your local web server.

    SSH is available for many platforms (Linux, Windows, OSX and more). You can build such tunnels quite easily with it, but you will of course need access to both computers you want to build the tunnel between. Let's say one computer is your own computer and another is a VPS you've rented (or any other remote server with SSH access). Now you can run exactly the same setup.

    The advantage with tunnlr is they manage the remote server for you, and they have a registered hostname you can use for your tunnels.