gh-net icon indicating copy to clipboard operation
gh-net copied to clipboard

A network bridge between a Codespace and a local machine.

Codespaces Network Bridge

๐Ÿงช The extension is currently in the Preview stage, so some hiccups are expected. Please help us to improve by submitting feedback!

image

This GitHub CLI extension allows you to bridge the network between a Codespace and your local machine, so the Codespace can reach out to any remote resource that is reachable from your machine. In other words, it uses your local machine as a network gateway to get to those resources.

For instance, if you are using a VPN client to connect to private enterprise network to access a database or any other remote resources, this extension enables you to use those private resources from within a Codespace.

About GitHub CLI.

Prerequisites

  1. This extension depends on the latest features of GitHub CLI(>= v2.8.0). Please make sure to upgrade it.

  2. The extension relies on gh codespace ssh command to establish SSH tunnel to a Codespace. If you use GitHub CLI >=2.13.0 the SSH config is created automatically for all your Codespaces, otherwise follow SSH setup instructions.

  3. If your Codespace uses a non-default image, ensure that both the GitHub CLI, openssh-server, and sudo are installed inside the codespace. Some distros need an ssh group too. Please see linux dependencies doc for per-distro instructions.

Installation

Mac OSx:

gh extension install github/gh-net

Linux:

sudo gh extension install github/gh-net

The sudo permissions are required during extension installation on Linux due to https://github.com/cli/cli/issues/5456. Hopefully, it won't be the case in the future.

Usage

To start network forwarding from a Codespace to a local machine, run:

sudo gh net start

Connection issues? Please see https://github.com/github/gh-net/issues/9 and SSH setup doc for some of the known solutions.

The command will first open a Codespace selection dialog:

image

Select a codespace and press enter. The extension will connect to selected codespace and start forwarding network traffic:

image

There are two panels in the connected view of the extension:

  • Panel on the left (NAT) shows the network address translation table for currently opened connections. For stateful protocols(e.g. TCP) the records are cleaned up automatically after a connection is closed, so the records will come and go as connections are established and teardown. For stateless protocols (e.g. UDP or ICMP) or unsuccessful TCP connections, the records are cleaned up after a delay; hence those may show up in the list for some time.
  • Panel on the right (DNS) shows the resolved DNS records, as hostname, record, and time-to-live (TTL) values.

Press q or ctrl + c to stop the extension.

CLI Options

  • --codespace(-c): Codespace name to connect to. [codespace name] [default: none]
  • --dns(-d): Enable/disable DNS resolution. [true | false] [default: true]
  • --gui(-g): Enable/disable GUI mode. [true | false] [default: true]
  • --trace(-t): Specify tracing verbosity. [none | trace | debug | info | warn | error] [default: info]
  • --trace-dest: Specify tracing destination file. [file name] [default: none]
  • --telemetry: Enable/disable sending diagnostics telemetry (no PII data is sent). [true | false] [default: true]

Run gh net start -h for details.

Supported platforms

Mac OSx

OS Local
Big Sur (v11) โœ…
Monterey (v12) โœ…

Linux

Distro Local Inside Codespace
Ubuntu โœ… โœ…
Debian โœ… โœ…
Fedora โœ… โœ…
Red Hat โœ… โœ…
Mint โœ… โœ…
OpenSUSE โœ… โœ…
Centos โœ… โœ…
Kali โœ… โœ…
Arch โœ… โœ…
Alpine โœ… โœ… *

Windows

Version Local
Windows 10 ๐Ÿƒ
Windows 11 ๐Ÿƒ

Supported architectures

Mac OSx

Architecture Status
Intel(AMD64) โœ…
Apple silicon (ARM64) โœ… *

Linux

Architecture Status
AMD64 โœ…
ARM64 โœ…
ARMv6 โœ…
ARMv7 โœ…

Windows

Architecture Status
AMD64 ๐Ÿƒ
i386 ๐Ÿƒ

Tested VPN Clients

Name Status
Viscocity โœ…
GlobalProtect โœ…
NordVPN โœ…
Tailscale โœ…

Legend: โœ… - supported ๐Ÿƒ - in progress ? - unknown / not tested


For list of supported network protocols refer to this doc.

Troubleshooting

Useful links