Open the web UIs on your private network like any public website. tunhub sets up the SSH forwarding for you.
A plain browser favourite opens AdGuard; tunhub starts the SSH tunnel on the way.
You self-host services with a web UI: Jupyter on a lab workstation, the admin
page of your NAS, AdGuard, Grafana, ... For security, they stay off the public
internet. So every time you need one, you first start an ssh -L forward, then
recall which local port it was, then type the address. Again and again, on every
computer you use.
tunhub takes those steps away. It runs quietly on your own computer: click a tile on its dashboard, or simply open a bookmark, and tunhub picks a route, opens the SSH tunnel if one is needed, waits until the service answers, and takes you there. When you are on the same LAN, it skips SSH and connects directly.
- One click from the hub. Click a tile and the service opens in a new tab, with the tunnel already up.
- Bookmarks that just work. Save
http://hub.localhost:1110/open/nasin your favourites bar and use it like any public website. If the tunnel is down, tunhub opens it on the way; you never think about it. - Direct when it can, SSH when it must. On the same LAN, tunhub connects directly (cyan dot). Everywhere else, it goes through SSH (purple dot).
- Addresses that never change. The NAS is always
http://nas.localhost:15000, whatever the route, so saved passwords and cookies keep working. - Not just web pages. RDP, VNC, databases and other TCP services get an on/off tile that copies their address for your client.
- Lightweight. One Python process using about 50 MB of memory and practically no CPU when idle, plus about 4 MB for each active ssh tunnel.
Get started
You need an OpenSSH client (built into Linux, macOS and Windows 10+) and Python 3.10+. Install tunhub with any of:
uv tool install tunhub # uv: its own environment; fetches Python if needed
pipx install tunhub # pipx: its own environment
pip install tunhub # pip: inside a virtual or conda environment
With pip, use a virtual or conda environment (many Linux distributions and
Homebrew refuse a system-wide pip install), and keep that environment:
tunhub service install starts tunhub with its Python. If the tunhub command
is not on your PATH, python -m tunhub does the same.
Then:
tunhub init # writes a commented example config
$EDITOR ~/.config/tunhub/services.yaml
tunhub # then open http://hub.localhost:1110
tunhub service install # optional: start automatically at login
Started without a config, the dashboard shows where the file goes and how to add your first service.
In Chromium-based browsers (Chrome, Edge, Brave) you can also install the dashboard as an app from the address bar. It then opens in its own window with its own dock or taskbar icon.
A service is a local port plus a list of routes, tried in order:
services:
nas:
local_port: 15000
routes:
- direct: 192.168.1.10:5000 # tried first, when you are at home
- ssh: nas # Host alias from ~/.ssh/config
remote: 127.0.0.1:5000 # as seen from the SSH server
SSH routes run non-interactively, so they need key authentication (or a loaded
ssh-agent) and a host that is already in known_hosts. Run ssh <alias> once
by hand for each host before you add it.
How it works
flowchart LR
B["Browser<br/>nas.localhost:15000"] --> P["127.0.0.1:15000<br/>(tunhub)"]
P -- "on the LAN: direct" --> N["NAS<br/>192.168.1.10:5000"]
P -- "elsewhere: ssh -L" --> S["SSH host"] --> N
Whichever route wins, the service is served at the same local address:
| route | what listens on 127.0.0.1:15000 |
|---|---|
| direct | a TCP relay inside tunhub (like socat) |
| ssh | ssh -N -L 127.0.0.1:15000:127.0.0.1:5000 nas |
Each web service gets its own host name, http://<id>.localhost:<local_port>.
Browsers share cookies between ports, but not between host names, so this keeps
logins and password-manager entries apart. Chromium-based browsers and Firefox
resolve *.localhost to 127.0.0.1 without any DNS setup.
Address or bookmark?
Every web service has two URLs, both shown in its ⋯ panel:
| example | what it is for | |
|---|---|---|
| Bookmark | http://hub.localhost:1110/open/nas |
Save this one in your browser. Opening it connects the service first (starting ssh if needed), then forwards you to the address. |
| Address | http://nas.localhost:15000 |
Where the service itself lives. Your password manager and cookies are tied to it, and it never changes with the route. It only loads while the service is connected. |
So you bookmark the hub link, and your password manager remembers the login under the address, without any extra setup.
Connection behaviour
A service is either in auto (the default) or on:
- Auto: every 15 s, tunhub probes the direct routes of idle services and brings a service up as soon as one is reachable (cyan, "Direct"). This only opens the local port; nothing is kept open to the target until you use it. Auto never starts ssh: when the direct route is lost, the service simply goes back to off.
- On: opening a service that is not up (tile click, bookmark, Start,
autostart: true) tries the routes in order, including ssh. If it comes up on a direct route, it is simply in auto; if it needs ssh (purple, "SSH"), it stays on: tunhub keeps it up, and if ssh dies it tries all routes again from the first, backing off from 2 s to 60 s while every route fails. A working ssh connection is kept even if a direct route becomes reachable, so live sessions are not cut; when it drops (e.g. the laptop changed networks), the reconnect prefers the direct route and the service is back in auto. Opening a service that is already up just opens it, so a laptop that leaves home does not start ssh tunnels it no longer needs. - Stop (shown only for a service that is on) ends the connection and
returns the service to auto; at home it is back on the direct route
within a second. A service with
auto_direct: falsehas no auto mode, so any connection to it is on until you stop it. There is no "stay off": setauto_direct: falsefor a service that should never connect by itself. Disconnect SSH in the top bar does the same for every service that uses or is trying ssh. - After a network change, ssh notices its dead connection within about 45 s (keep-alive). To switch immediately, click Stop and then the tile.
The ⋯ button on a tile shows its address, bookmark URL, route choice and live log:
Configuration
tunhub init creates the config directory with a commented example:
| OS | config directory |
|---|---|
| Linux | $XDG_CONFIG_HOME/tunhub or ~/.config/tunhub |
| macOS | ~/.config/tunhub |
| Windows | %APPDATA%\tunhub |
To use another directory, set TUNHUB_CONFIG_DIR or pass --config-dir.
services.yamlis the shared definition: the same file on every machine. Sync the whole directory between your machines (a dotfiles repo, a synced folder, ...).local.<machine>.yamlholds optional overrides for one machine and is merged on top ofservices.yaml: mappings key by key, lists such asroutesas a whole.<machine>is the name shown next to the dashboard's title (the host name, lowercased, up to the first dot;TUNHUB_MACHINEor--machinesets another). Each machine reads only its own file. Seelocal.example.yaml.
Write the routes as "how to reach this service from my other computers":
direct for networks where you can reach it directly (one direct per
network if its address differs), ssh for everywhere else. Keep machine
differences out of services.yaml:
- If machines reach a server differently over ssh (a jump host from outside,
a plain connection inside), give the same
Hostalias a different definition in each machine's~/.ssh/config. - A port that is taken on one machine, or a service that one machine should
not show (
enabled: false), goes into that machine's local file.
Click Reload config in the dashboard after editing. Services whose
definition did not change keep their connections. Changes to the hub:
section need a restart. Problems that do not stop tunhub, such as a misspelt
key, are shown in a yellow box on the dashboard until you fix them.
Running tunhub on the machine that hosts a service
Nothing special is needed. If the service listens on the LAN, its direct
route works on that machine too. If it only listens on 127.0.0.1, the ssh
route still works (ssh to itself). To skip ssh there, add a
direct: 127.0.0.1:<port> route in that machine's local file, never in
services.yaml: 127.0.0.1 is a different machine on every computer. Its
local_port must differ from the service's own port.
Every key is explained in the comments of the example files that tunhub init
writes: services.yaml and
local.example.yaml.
Start at login
tunhub service install # also: uninstall, status
| OS | mechanism | logs |
|---|---|---|
| Linux | systemd user unit tunhub.service |
journalctl --user -u tunhub -f |
| macOS | LaunchAgent | ~/Library/Logs/tunhub.log |
| Windows | Task Scheduler (pythonw, no console window) |
%LOCALAPPDATA%\tunhub\tunhub.log |
The service runs the same Python interpreter that installed it, with the
config directory that tunhub service install used, and the machine name if
you chose one (TUNHUB_MACHINE or --machine). Both are written into the
service, so it does not depend on your shell's environment. After moving the
config directory, run tunhub service install again.
This starts tunhub at login. A service's autostart: true is different: it
connects that service whenever tunhub starts.
On Linux, the systemd user session must see your ssh-agent (SSH_AUTH_SOCK);
GNOME's agent normally takes care of that.
On Windows, stop tunhub before upgrading it, because Windows cannot replace a
program that is running (uv then fails with "Access is denied"):
Stop-ScheduledTask -TaskName TunHub
uv tool upgrade tunhub
Start-ScheduledTask -TaskName TunHub
Security
- The dashboard and all forwards listen on this machine only (127.0.0.1;
hub.listenaccepts only loopback addresses such as::1). - Requests whose
Hostis not the dashboard's own host name are rejected, which blocks DNS rebinding. - State-changing API calls need a custom header and a same-origin
Origin, so other web pages cannot trigger them. - Other web pages cannot open a tunnel through
/open/<id>either (for example with a hidden<img>): tunhub only accepts bookmarks, typed URLs, the dashboard itself and links that you click. - The dashboard refuses to be shown inside another site's frame (clickjacking).
- Only services defined in your config can be opened. The web UI never runs arbitrary commands.
- Service icons are fetched only through the service's own local port; tunhub
never contacts other sites. They are served with a sandboxing CSP and shown
only as
<img>.
Direct routes on other networks: known_macs
Private addresses are reused everywhere. In a café whose network also uses
192.168.1.x, another device might answer on your NAS's address, and the
browser would send it your NAS cookies. tunhub avoids such accidental
misconnections the way ssh handles host keys with known_hosts:
- The first time a direct route connects, tunhub records the MAC address of
the next hop toward the target (the target itself on the same subnet, else
the router) in
known_macs, next toservices.yaml:Permanently added 192.168.1.10 (aa:bb:cc:dd:ee:01) to known_macs. - Later, a direct route is used only if that MAC matches. Otherwise it is skipped (falling back to ssh, if configured) and the tile shows ⚠.
- When the network changes, or cannot be determined, running direct routes are checked again; a route that still reaches the same machine stays up.
- If a MAC changes for a good reason (new network card, another router),
run
tunhub forget <ip>or editknown_macs; several lines for one IP are all trusted. The file can be synced together with your config.
This prevents accidents, not deliberate attacks: someone on the same network can fake a MAC. Targets reached through a VPN have no visible MAC and are used without this check. Give direct targets a fixed address (a static IP or a DHCP reservation): a running direct route is re-checked when the network changes, not when an address is handed to another machine on the same network.
How does it compare?
| opens on click | picks direct or SSH | nothing on servers | non-web services | |
|---|---|---|---|---|
| tunhub | ✅ | ✅ | ✅ | ✅ |
| SSH tunnel managers (GUI / web) | – | – | ✅ | ✅ |
| Homelab dashboards (Homer, Homepage, Dashy) | ✅ | – | ✅ | – |
| Mesh VPNs (Tailscale, ZeroTier, WireGuard) | – | ✅ | – | ✅ |
- SSH tunnel managers handle individual
-Lforwards. You still map ports to services in your head, and nothing connects when you open a bookmark. - Homelab dashboards are link pages: they can't reach a service that needs a tunnel.
- Mesh VPNs are great when you can install an agent on every server. tunhub is for the places where you can't or don't want to: university or company machines reachable only over SSH, jump hosts, or a NAS you would rather not run a VPN on.
What tunhub is not
- Not a VPN and nothing to install on your servers: it uses the SSH access you already have. For a mesh network, use Tailscale, ZeroTier or WireGuard.
- Not a way to publish services: everything listens on 127.0.0.1, and the dashboard is for you alone, with no login and no access from other devices. For public URLs, see ngrok or Tailscale Funnel.
- Not an SSH client: it runs your system's OpenSSH with your
~/.ssh/config, so jump hosts, certificates, agents and hardware keys work as they do in your terminal. - Not an HTTP proxy: it forwards bytes, so any protocol works, but it does not rewrite headers or terminate TLS.
- Not a monitoring or discovery tool: it opens the services you list. For status pages and alerts, see Uptime Kuma or Homepage.
- Not a config editor: you write the YAML; tunhub never changes it.
Development
git clone https://github.com/LiukDiihMieu/tunhub && cd tunhub
uv sync --extra dev
uv run pytest
uv run tunhub --config-dir ./my-test-config
Changes follow the compatibility rules in
docs/COMPATIBILITY.md:
config files, bookmarks, addresses, known_macs and the command line keep
working across upgrades, while the HTTP API under /api/ is internal to the
dashboard.
The tests use tests/fake_ssh.py in place of ssh to exercise the SSH routes,
including reconnecting after the ssh process is killed.
Icons, logos and the social preview image are generated by
tools/make_icons.py; see its docstring to regenerate them.
License
GPL-3.0-or-later. You may use, modify and redistribute tunhub, but any distributed modified version or derivative work must also be released under the GPL.
Metadata
Release files for tunhub 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tunhub-0.2.0.tar.gz | 177.3 kB | With provenance | Details for tunhub-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tunhub-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for tunhub-0.2.0-py3-none-any.whl |
Total release size: 332.3 kB
Release files / tunhub-0.2.0.tar.gz
| Download URL | tunhub-0.2.0.tar.gz |
|---|---|
| Size | 177.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0562497661032850af555f65eb2d8583ab096d357f426fc22398015f35cedb1
|
|
BLAKE2b-256 checksum How to use checksums |
956adaf50937fb6d01bd38b710903f1b97506f83ba75ee719c20464abdd064a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tunhub-0.2.0-py3-none-any.whl
| Download URL | tunhub-0.2.0-py3-none-any.whl |
|---|---|
| Size | 155.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab3629c7a77b56028fad651f92c2f1d79f862b56f9ff114de4bee471ae698833
|
|
BLAKE2b-256 checksum How to use checksums |
c5bcb1e7943ab5951547b1dc4d2de8427794799e46f7f26b3aecc43a8996d1d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logSecurity for tunhub 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tunhub-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.