porthole

module
v0.3.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0

README

porthole

A self-hosted, open-source alternative to ngrok: expose a service behind NAT through your own server, and reach your machines over SSH by name.

CI Release OpenSSF Scorecard Go Report Card Go version

Install | Server | Client | SSH by name | Design | Releases

You run one server, portholed, on a machine with a public IP address and a domain. On any machine behind NAT you run the client, porthole. No public instance, no usage limits, no account with a third party: you own the server, the domain and the data. The headline use case is ssh -J tun.example.com:2222 alice@home with stock OpenSSH and nothing installed on the machine you connect from. Management of the server by LLM agents (admin API and MCP server) is next on the roadmap.

Status: alpha. Only preview releases exist so far. The wire protocol, the configuration format and the CLI may still change before the first stable release. Do not rely on it for anything you cannot afford to break. This README describes main; check the release notes of the version you install.

Quick start

# On the server (public IP, domain and wildcard DNS record, TLS certificate: see docs/server.md)
$ curl -fsSL https://raw.githubusercontent.com/eto-a/porthole/main/install.sh | sh -s -- --server
$ sudo -u porthole portholed join create --name home       # prints a one-time `porthole join` command

# On your machine, behind NAT
$ curl -fsSL https://raw.githubusercontent.com/eto-a/porthole/main/install.sh | sh
$ porthole join https://tun.example.com/j/pj_3kq9w2m1z8xa_....    # works once, valid for 15 minutes
$ porthole http 3000
connected as home
https://http-3000-home.tun.example.com -> 127.0.0.1:3000

The first command only installs the server: edit /etc/porthole/portholed.yaml and start the service as described in Server setup before creating the join link (it needs the running server). A join link hands the machine its own token without anyone copying a secret; portholed token create and porthole login remain for scripted setups.

Use cases

Publish a web application (HTTPS and WebSocket, one subdomain per tunnel):

$ porthole http 8080                       # https://http-8080-home.tun.example.com
$ porthole http 192.168.1.10:3000 --name blog   # https://blog-home.tun.example.com

SSH to a home machine behind NAT, by name. On the machine (it needs an sshd), run porthole ssh; it prints the command. Anywhere else, with plain OpenSSH:

$ ssh -J tun.example.com:2222 alice@home

or once in ~/.ssh/config, then just ssh home (also scp, sftp, rsync):

Host home
    HostName home
    User alice
    ProxyJump tun.example.com:2222

The gateway only forwards, never gives a shell on the server, and never sees your password or key. Compare its host key fingerprint (portholed ssh-hostkey) on the first connection. Details: SSH by name.

Private SSH: porthole ssh --private makes the gateway ask for a porthole token before it opens the tunnel; you select this with the user name token:

$ ssh -J token@tun.example.com:2222 alice@home

A TCP service (database, game server, anything), on a port of the server's range:

$ porthole tcp 5432                        # tcp://tun.example.com:<port from the range>
$ porthole tcp nas.local:5432 --remote-port 20017

Several tunnels that survive reboots. List them in tunnels.yaml and run the client as a service:

version: 1
tunnels:
  blog: {type: http, addr: 3000}
  db:   {type: tcp, addr: "nas.local:5432"}
  ssh:  {type: ssh}
$ sudo systemctl enable --now porthole     # deb/rpm package; or `porthole start` in the foreground
$ porthole status

See the Client guide for the daemon, user units and --detach.

Features

Self-hosted One static binary per side, no CGO; systemd units, deb/rpm packages and distroless Docker images (install)
Client-driven Tunnels are configured on the client; the server allocates the address and only issues tokens
Outbound-only client One TLS connection to the server on port 443, so it works behind NAT and most corporate firewalls; reconnects automatically
Protocols HTTP(S) and WebSocket (subdomain per tunnel), TCP (port from a configured range), SSH (by name through the gateway)
Tokens Created, listed and revoked on the server; they can expire and carry scopes and tunnel limits; a token is a client identity, and each client sees only its own tunnels and names
Stable addresses HTTP names are derived from the tunnel name; TCP ports stay reserved for a client and tunnel name for 24 hours, also across server restarts
TLS From certificate files (renewals picked up without a restart) or behind a reverse proxy such as Caddy (server setup)
Agent-managed MCP servers for LLM agents: an operator endpoint on the server (/_porthole/mcp, bearer token with scopes, toolsets, --read-only, audit log; list and search clients, tunnels and traffic, replay recorded requests, open a tunnel on a connected client on request, create single-use join links) and porthole mcp for opening tunnels on a machine (agents)
Supply chain Signed releases (cosign), build provenance attestations, SBOMs (verify a download)
How it compares
porthole ngrok frp cloudflared sish
You run the server yes no, hosted service yes no, Cloudflare network yes
On the machine behind NAT porthole ngrok agent frpc cloudflared plain ssh -R
SSH by name with only OpenSSH on the connecting side yes (ssh -J) see its docs see its docs needs cloudflared or WARP on the visitor yes (TCP aliases)

Statements about other tools come from their public documentation and are simplified; check them before deciding. No performance claims are made here.

How it works

                      HTTPS / TCP / ssh -J
   visitors ------------------------------->  portholed  <======================  porthole
 (browser, ssh, ...)    tun.example.com       (your VPS)    one outbound TLS       (behind NAT)
                                                            session, many streams       |
                                                                                        +--> 127.0.0.1:3000
                                                                                        +--> nas.local:5432
                                                                                        +--> 127.0.0.1:22

The client opens one outbound WebSocket-over-TLS session to portholed and multiplexes everything over it (yamux). Inside the session there is one control stream (login, tunnel registration, heartbeats) and one data stream per visitor connection, opened by the server. The client never interprets proxied bytes: for each data stream it dials the local target and copies bytes both ways. HTTP routing by Host, TLS and WebSocket upgrades all live on the server.

Documentation

Status

Alpha. Roadmap, from DESIGN.md: v0.2 "install and forget" (install script, deb/rpm and Docker, client daemon, SSH gateway by name, private SSH tunnels, persisted port reservations); v0.3 management by LLM agents (admin API and MCP server) instead of a web UI; v0.4 QUIC, UDP and more HTTP access control.

Security

Tokens are 256-bit secrets stored only as hashes; authorization is re-checked on every tunnel registration and revocation applies to live sessions. Please report vulnerabilities privately as described in SECURITY.md, not in public issues.

Contributing

Contributions are welcome; please read CONTRIBUTING.md first. Contributions require a Developer Certificate of Origin sign-off (git commit -s). By participating you agree to follow the Code of Conduct. To build from source (Go 1.27 or newer): make build, see Installation.

License

Apache License 2.0. See LICENSE and NOTICE.

Directories

Path Synopsis
cmd
porthole command
Command porthole exposes local services through a porthole server.
Command porthole exposes local services through a porthole server.
portholed command
Command portholed is the porthole server.
Command portholed is the porthole server.
internal
adminapi
Package adminapi is the server's management API (ADR 0005): HTTP+JSON over a local unix socket (access is the file permission, full admin) and over the public listener under Prefix (bearer token with admin:* scopes).
Package adminapi is the server's management API (ADR 0005): HTTP+JSON over a local unix socket (access is the file permission, full admin) and over the public listener under Prefix (bearer token with admin:* scopes).
auth
Package auth implements porthole client tokens: `ph_<id>_<secret>`.
Package auth implements porthole client tokens: `ph_<id>_<secret>`.
cli/clientcmd
Package clientcmd implements the command line of the porthole client binary.
Package clientcmd implements the command line of the porthole client binary.
cli/exitcode
Package exitcode defines the process exit statuses of porthole and portholed, and runs a cobra command tree so that every failure ends in one of them (and, with --json, in an error document on stdout).
Package exitcode defines the process exit statuses of porthole and portholed, and runs a cobra command tree so that every failure ends in one of them (and, with --json, in an error document on stdout).
cli/jsonout
Package jsonout implements the --json mode shared by the porthole and portholed command lines.
Package jsonout implements the --json mode shared by the porthole and portholed command lines.
cli/servercmd
Package servercmd provides the `portholed serve` command.
Package servercmd provides the `portholed serve` command.
cli/tokencmd
Package tokencmd implements "portholed token create|list|revoke".
Package tokencmd implements "portholed token create|list|revoke".
client
Package client implements the porthole client: one outbound session to the server, tunnel registration, forwarding of data streams to local targets, and reconnection with exponential backoff.
Package client implements the porthole client: one outbound session to the server, tunnel registration, forwarding of data streams to local targets, and reconnection with exponential backoff.
clientconfig
Package clientconfig loads and validates the client tunnels file (tunnels.yaml): a list of named tunnels that the porthole client daemon (or `porthole start`) keeps up.
Package clientconfig loads and validates the client tunnels file (tunnels.yaml): a list of named tunnels that the porthole client daemon (or `porthole start`) keeps up.
config
Package config loads and validates the portholed server configuration (DESIGN.md §3.9).
Package config loads and validates the portholed server configuration (DESIGN.md §3.9).
daemon
Package daemon is the porthole client daemon: one long-lived session to the server carrying a mutable set of tunnels, controlled over the local API (internal/localapi) and by the tunnels file (internal/clientconfig).
Package daemon is the porthole client daemon: one long-lived session to the server carrying a mutable set of tunnels, controlled over the local API (internal/localapi) and by the tunnels file (internal/clientconfig).
localapi
Package localapi is the local control API of the porthole client daemon: HTTP/1.1 + JSON over a unix domain socket (see docs/adr/0002-client-daemon-and-tunnels-file.md).
Package localapi is the local control API of the porthole client daemon: HTTP/1.1 + JSON over a unix domain socket (see docs/adr/0002-client-daemon-and-tunnels-file.md).
mcp/client
Package client is the MCP server of an agent on a client machine (ADR 0005, surface B): `porthole mcp` serves tools that open and close tunnels through the local daemon.
Package client is the MCP server of an agent on a client machine (ADR 0005, surface B): `porthole mcp` serves tools that open and close tunnels through the local daemon.
mcp/server
Package server is the operator MCP server (ADR 0005, surface A): the tools an agent uses to look after a porthole server.
Package server is the operator MCP server (ADR 0005, surface A): the tools an agent uses to look after a porthole server.
metrics
Package metrics holds the Prometheus instrumentation of portholed and the HTTP handler that serves it together with the Go profiler.
Package metrics holds the Prometheus instrumentation of portholed and the HTTP handler that serves it together with the Go profiler.
proto
Package proto implements the porthole control protocol described in docs/protocol.md: length-prefixed JSON frames exchanged on the control stream and at the start of data streams.
Package proto implements the porthole control protocol described in docs/protocol.md: length-prefixed JSON frames exchanged on the control stream and at the start of data streams.
server
Package server implements portholed: it accepts client sessions over WebSocket+yamux (docs/protocol.md), keeps the registry of tunnels and routes public HTTP and TCP traffic into them (DESIGN.md §3.5).
Package server implements portholed: it accepts client sessions over WebSocket+yamux (docs/protocol.md), keeps the registry of tunnels and routes public HTTP and TCP traffic into them (DESIGN.md §3.5).
store
Package store persists server state: client tokens (v0.1) and port reservations (v0.2).
Package store persists server state: client tokens (v0.1) and port reservations (v0.2).
traffic
Package traffic keeps the in-memory journal of proxied HTTP requests and tunnel connections (ADR 0005).
Package traffic keeps the in-memory journal of proxied HTTP requests and tunnel connections (ADR 0005).
transport
Package transport provides the multiplexed session between a porthole client and server.
Package transport provides the multiplexed session between a porthole client and server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL