←  back to blog
Gitpod Local Companion - localhost is going remote

Gitpod Local Companion - localhost is going remote

While Gitpod can seamlessly integrate into your workflow in the vast majority of cases, there are times where you may want to access a workspace from localhost and were required to workaround some limitations, particularly with respect to framework features such as live reload.

Gitpod is pleased to announce a preview release of the Gitpod Local Companion app that is designed to allow localhost access to any TCP port in a remote workspace regardless of protocol.

The app runs locally and enables automatically tunneled connections to your workspace, either privately or, if required, publicly (on your laptops IP for example).

In particular, this opens up any environment or framework that assumes localhost access i.e. web frameworks such as Svelte and enables bundlers such as Parcel or Webpack hot reloading without requiring any changes. It also enables the use of non-HTTP protocols, most notably MQTT based brokers or the AMQP based services.

As a preview release, not all of the features are implemented, most notably the tunneling is 1-way only: local -> workspace.

💡 Notice: A lot has improved on local-companion and the port-forwarding aspect since the publication of this blog post. You could also simply open a Gitpod workspace in VS Code Desktop or any other supported local editor client and your ports would be automatically forwarded for you! See the below links to learn more:

See it in action

As a simple example, with the Gitpod Local Companion app installed and running, open the standard Svelte template in Gitpod, using this link or the Gitpod button directly. This will create an ephemeral environment for you without requiring any local setup or installation. As per the template instructions, run the following:

language icon bash
npm install && npm run dev

VS Code will detect the service on port 5000 and offer 3 options. Click on the ‘Open Browser’ icon or navigate to directly to localhost to see ‘Hello world!‘. Edit app.svelte and the page will live reload with your changes!

We love feedback here at Gitpod, so please give it a try and let us know what you think!

Installation

To get started, download the preview release of the Gitpod Local Companion app for your platform (right click, ‘Save (Link) As’)

Alternatively, in a terminal run the following:

language icon bash
  # Mac Intel Chip
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-darwin
  chmod +x ./gitpod-local-companion-darwin

  # Mac Apple Silicon
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-darwin-arm64
  chmod +x ./gitpod-local-companion-darwin-arm64

  # Linux 64 bit
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-linux
  chmod +x ./gitpod-local-companion-linux

  # Linux ARM 64
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-linux-arm64
  chmod +x ./gitpod-local-companion-linux-arm64

  # Windows 64 bit
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-windows.exe

  # Windows 32 bit
  curl -OL https://gitpod.io/static/bin/gitpod-local-companion-windows-386.exe

Running

To run it using your local keyring for long term storage of the access token:

language icon bash
  ./gitpod-local-companion-[darwin|linux|windows]

To run it without storing the access token (it will generate a new token every time);

language icon bash
  ./gitpod-local-companion-[darwin|linux|windows] --mock-keyring

If you are not logged in to Gitpod, it will take you through that flow. If you haven’t run the local app previously it will also ask you to approve access to the control data of all your workspaces, returning a token that grants the access. This token will be stored in your local keyring for future use (unless you specify otherwise).

Once approval has been granted it will connect to your currently active workspaces and tunnel between the remote workspace and your local environment.

SSH Access

Additionally, the Gitpod Local Companion preview release also has basic support for SSH access into your workspace. It currently requires that you have a default SSH key setup in the ~/.ssh directory i.e. id_rsa.pub & id_rsa. The public key will be copied to the workspace to permit access.

This opens up all the usual SSH-based features, such as secure copying, tunneling and remote execution.

Once you have installed the Gitpod Local Companion app and connected it to your workspaces, it dynamically creates entries for each workspace in the /tmp/gitpod_ssh_config file. You can use this to SSH into your workspace as follows:

language icon bash
ssh -F /tmp/gitpod_ssh_config <your-workspace-id e.g.apricot-harrier-####>

You will be prompted to add the address to your known hosts file and you will be connected to your workspace!

What is next?

We have big plans for the Gitpod Local Companion App! Future features may include:

  • 2-way tunnelling
  • Listing what workspaces are running
  • Listing what ports are currently tunneled and in which direction (workspace to/from local)
  • Starting/stopping port forwarding from the command line
  • Connecting a local VS Code instance to a workspace
  • SSH into a workspace from the command line in a simple, straight forward way
Join developers, everywhere.

Development environments pre-configured with the tools and dependencies needed to get inspired and start building.

Related articles

Monthly Newsletter

Subscribe to get a summary of what we've shipped over the last month, plus everything you need to know around developer experience.

By submitting this form, I confirm that I acknowledge the collection and processing of personal data by Gitpod, as further described in the Privacy policy.