porthole

module
v0.4.0-alpha.9 Latest Latest
Warning

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

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

README

porthole

Self-hosted tunnels your AI agent can run.

porthole is an open-source alternative to ngrok that runs on your own server. It publishes local web services over HTTPS, forwards TCP ports and lets you SSH into machines behind NAT by name. It has an MCP server built in, so Claude Code or any other agent can expose ports, inspect traffic and enrol new machines for you.

CI Release OpenSSF Scorecard Go Report Card Go version

Quick start | Install | Agents | Server | Client | SSH by name | Recipes

Alpha. Only preview releases exist so far. The wire protocol, the configuration format and the CLI may still change. This README describes main; check the release notes of the version you install.

Install with your agent

Paste this into Claude Code, or any coding agent that can run shell commands:

Set up porthole for me: follow https://raw.githubusercontent.com/eto-a/porthole/main/docs/agent-install.md — ask me only what you can't find out yourself.

The agent asks for what it cannot detect (your VPS, your domain, which ports to open), installs the server and the clients, creates join links, checks that a tunnel works and, if you want, connects itself to porthole over MCP. The instructions tell it to ask before opening firewall ports and to keep tokens out of the chat. The full instructions it follows: docs/agent-install.md.

Install by hand

porthole has two parts: a server you set up once, and a client on every machine. There is no public instance and no third-party account: you own the server, the domain and the data. The whole path, step by step: Quick start.

Server (once, on a VPS)

Point tun.example.com and *.tun.example.com at the server's IP address, then:

$ curl -fsSL https://raw.githubusercontent.com/eto-a/porthole/main/install.sh | sh -s -- --server
$ sudoedit /etc/porthole/portholed.yaml                 # set "domain: tun.example.com"
$ sudo systemctl enable --now portholed                 # open ports 80 and 443 first
$ sudo -u porthole portholed join create --name home    # a one-time link for the first machine

HTTPS certificates come from Let's Encrypt automatically, one per host name, with no DNS provider to configure. Packages, Docker and Dokploy: Installation and Deploy.

Clients (on every machine)
$ 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

More everyday commands:

$ porthole http 192.168.1.10:3000 --name blog   # https://blog-home.tun.example.com
$ porthole tcp 5432                             # tcp://tun.example.com:<port from the range>
$ porthole ssh                                  # prints the ssh -J command for this machine
$ ssh -J tun.example.com:2222 alice@home        # from anywhere, with stock OpenSSH

For tunnels that survive reboots, list them in tunnels.yaml and run the client as a service; porthole status then shows the daemon's connection and tunnels (it needs the daemon). Windows and macOS archives, packages and the Docker sidecar: Installation; the daemon: Client guide.

What your agent can do

You:    Expose port 8080 on home
Agent:  request_tunnel {client: "home", kind: "http", local_addr: "8080"}
        -> https://http-8080-home.tun.example.com

You:    What hit my webhook in the last 10 minutes?
Agent:  query_requests {since: "10m"}

You:    Add my new laptop
Agent:  create_join_link {client: "laptop"}
        -> run on the laptop: porthole join https://tun.example.com/j/pj_...

Connect Claude Code to your server and to a machine:

$ claude mcp add porthole -- ssh root@tun.example.com portholed mcp --read-only    # the server, over SSH
$ claude mcp add porthole-local -- porthole mcp                                    # this machine

The server can also be reached over HTTPS with a token; tools, scopes and toolsets are in Agents. Without MCP, every command takes --json and has stable exit codes (machine-readable output).

Safe to hand to an agent:

  • Scopes. Every tool checks a scope; a token with only admin:read can look but not change anything, and --read-only registers no mutating tool at all.
  • Audit. Every mutating call is logged with the token that made it, refusals included.
  • No secrets in the chat. create_join_link returns a single-use, 15-minute link; the machine's permanent token never passes through the conversation. No tool returns a long-lived secret.
  • The machine has the last word. The server can ask a client to open a tunnel only if the client's token allows it, and by default only for the machine's own ports. Other hosts on its LAN need to be listed in allow_remote on that machine.

Features

  • HTTPS with automatic certificates. One subdomain per HTTP or WebSocket tunnel; certificates from Let's Encrypt without a DNS provider (TLS).
  • SSH by name. ssh -J tun.example.com:2222 alice@home with stock OpenSSH; scp, sftp and rsync work too. The gateway only forwards and never sees your password or key (SSH by name).
  • TCP. A database, a game server, anything, on a port from the server's range.
  • Tunnels that stay up. A tunnels.yaml file and a systemd service for the client.
  • Traffic log and inspector. Search requests, see what a webhook sent, replay it (Request log).
  • Outbound-only client. One TLS connection on port 443, so it works behind NAT and most corporate firewalls, and it reconnects by itself.
  • Signed releases. Archives, deb and rpm packages and container images, with cosign signatures and build provenance (verify a download).

How it compares

Short answers, simplified from the public documentation of each tool; check it before you decide. No performance claims are made here.

  • Choose ngrok if you want a hosted service and do not want to run a server at all. The server side is ngrok's.
  • Choose Cloudflare Tunnel (cloudflared) if your domain is already on Cloudflare and you want its network in front. The server side is Cloudflare's, and for SSH its documentation has the connecting side run cloudflared or WARP.
  • Choose frp if you want a self-hosted tunnel that already handles UDP and many proxy types, configured in frps and frpc files. porthole has no UDP yet.
  • Choose sish if the machine behind NAT should run nothing but plain ssh -R.
  • Choose porthole if you want to run the server yourself and let an agent manage it over MCP, with automatic HTTPS per tunnel, one-time join links and SSH by name for visitors who have only OpenSSH.

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): one control stream for login, tunnel registration and heartbeats, and one data stream per visitor connection, opened by the server. For each data stream the client dials the local target and copies bytes both ways without interpreting them. HTTP routing by Host, TLS and WebSocket upgrades all live on the server. Details: DESIGN.md and the wire protocol.

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, MCP servers, join links, remote tunnel requests and a traffic inspector, instead of a web UI.
  • v0.4, desktops: Windows and macOS clients, porthole service for systemd, launchd and the Windows service manager.
  • v0.5, protocols: 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. Commits need a Developer Certificate of Origin sign-off (git commit -s), and participants follow the Code of Conduct. To build from source (Go 1.27 or newer): make build, see Building from source.

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.
Package deploy embeds the service definitions that ship in this directory, so that the packages and `porthole service install` use the same text and cannot drift.
Package deploy embeds the service definitions that ship in this directory, so that the packages and `porthole service install` use the same text and cannot drift.
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).
service
Package service installs and controls the porthole client daemon as an operating system service: a systemd unit on Linux, a launchd job on macOS and a Windows service (SCM) on Windows (ADR 0006).
Package service installs and controls the porthole client daemon as an operating system service: a systemd unit on Linux, a launchd job on macOS and a Windows service (SCM) on Windows (ADR 0006).
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