Ordered steps that produce a working tunnel when run. Work top to bottom on a first setup; each section stands alone on later passes.
1. Install
Build once, ship twice — from the crate’s own directory:
cargo build --release --locked
The binary runs in place from target/release/qqt, so a session working in this checkout puts that directory on PATH. On a box you ship to, the binary is the shipped file itself: the systemd units and the boot guard expect it at /usr/local/bin/qqt and /root/qqt respectively, and one copy at its final path is the rule — a second copy beside it drifts silently and the units keep running the old one.
The same binary runs the server and the client. Nothing else is needed — no config files, no runtime data outside the cert dir. Three completions ship in completions/, and they carry the same surface: _qqt (zsh), qqt.bash, and qqt.fish. For zsh, put that directory on $fpath BEFORE compinit runs (or symlink the file into a directory already on the path) — $fpath is read once, so a shell that already ran compinit needs it run again. For bash, source qqt.bash from your .bashrc after bash-completion, or drop it in share/bash-completion/completions/qqt; for fish, copy qqt.fish to ~/.config/fish/completions/. Tab then covers every subcommand, flag, and spec field, and a host name wherever one is taken — read from the same ssh host list the command reads, Included files and all.
2. Mint and distribute certs
Run on the operator’s machine (the one place the CA key is allowed to live):
qqt gencert -o ./qqt-certs
The output tree:
qqt-certs/
├── ca-cert.pem ship everywhere (it is public)
├── ca-key.pem never leaves the operator
├── server/ ship to the tunnel server
│ ├── ca-cert.pem
│ ├── server-cert.pem
│ └── server-key.pem
└── client/ ship to the tunnel client
├── ca-cert.pem
├── client-cert.pem
└── client-key.pem
Custody rules:
The CA key stays with the operator. Anyone holding it mints client certs — treat it like a root password.
Ship
server/to the server andclient/to the client over a channel you trust (scp, a password manager’s file vault). The certs are public; the role keys are not. The conventional landing spots are/etc/qqt/server-certsand/etc/qqt/client-certs, which is what the units and the rest of this runbook use — on each box:scp -r ./qqt-certs/server host:/etc/qqt/server-certsKeep the CA key (
ca-key.pem) on the operator box; it never ships.Leaf certs are valid 365 days by default (
--valid-days, enforced by the TLS handshake on both sides) —qqt expiry <pem>prints the window, and the rollover procedure is instructions_qqt-remint.md §3.A leaked cert is revoked, not outlived:
qqt revoke --cert <pem> --revoked <list>appends its fingerprint to a list the server re-reads at every handshake (instructions_qqt-remint.md §4).Serving untrusted customers? Mint each customer under their own CA (
qqt mint --customer <name>) so no admitting key is ever in your custody (instructions_qqt-remint.md §1–2).
gencert refuses to overwrite an existing set without -f. Two concurrent gencert runs on the same directory are serialized by a lock file — the second exits with an error, not a mixed cert set.
3. Run the server
The server needs one reachable UDP port and its cert dir:
qqt server --listen 0.0.0.0:4433 --certs-dir /etc/qqt/server-certs
Proof it is up: the log line ok: listening on udp 0.0.0.0:4433 — followed by a client’s ok: connected on the other side. Every rejected handshake logs handshake rejected: ... with the TLS error.
On a box with both families, bind the wildcard IPv6 address instead: it answers IPv4 as well, so one listener serves both.
qqt server --listen [::]:4433 --certs-dir /etc/qqt/server-certs
The proof line names what is bound: ok: listening on udp [::]:4433. That listen takes an IPv4 client on any kernel. Adding -6 makes the same wildcard v6-only instead: the flag narrows reach, it never widens it. Why: docs/rationale_qqt-address-family.md.
Under systemd, use examples/qqt-server.service: it runs the server with a read-only view of the filesystem, no new privileges, and nothing else. The unit arms --revoked /etc/qqt/revoked.txt, and a missing list is a startup error, so land one with the certs — empty is fine:
install -m 0640 /dev/null /etc/qqt/revoked.txt
To ship and start the server on a remote box instead, qqt up does the remote half: it streams this binary to --dest, stops the old server, starts the new one under setsid, and proves the door with a real mTLS handshake. Land server/ on the box first at an absolute path — the cert set is never re-shipped — and give --verify the public address; --dry-run prints the plan first (the cert pre-flight and the post-start check are the real run’s). The remote side must be Linux (the start line is setsid plus pgrep -f):
ssh root@203.0.113.10 'mkdir -p /etc/qqt' # scp -r does not create it
scp -r ./qqt-certs/server root@203.0.113.10:/etc/qqt/server-certs
qqt up root@203.0.113.10 --listen 0.0.0.0:4433 \
--certs-dir /etc/qqt/server-certs \
--client-certs-dir ./qqt-certs/client \
--verify 203.0.113.10:4433
The remote start line carries --stats 10 by default: the box has no journal, so the tunnel’s own log file is the only view. --stats SECS changes the cadence.
4. Run the client
One -l per forward, one -r for the server:
qqt client \
-l 127.0.0.1:15432:10.0.0.5:5432 \
-l 127.0.0.1:18080:10.0.0.5:8080 \
-r 203.0.113.10:4433 \
--certs-dir /etc/qqt/client-certs
Each listener logs its bound address and target at startup. Bind port 0 asks the OS for an ephemeral port and the startup line names the port actually bound.
A reverse forward swaps the sides: the bind ends up on the server, the target is dialed by the client.
qqt client \
-R 127.0.0.1:18080:127.0.0.1:8080 \
-r 203.0.113.10:4433 \
--certs-dir /etc/qqt/client-certs
Now 127.0.0.1:18080 on the server is 127.0.0.1:8080 as the client sees it: each connection to the server’s port rides the tunnel back, and the client dials the target from its own network position. The server confirms each bind with a log line on both ends. A bind the server cannot make is a warning on the client and the -l forwards keep running — but note the server first retries an in-use bind for up to ~70 s (a redial can race the server’s reaping of a dead predecessor’s port), so a genuinely taken port surfaces as a warning only after that wait. The listener lives exactly as long as the connection — with --reconnect every redial asks for the binds again, so the port returns with the tunnel. A clean exit tells the server to drop the listener at once (the port is back in about a second); a client that died without a close leaves the server holding the port until its 60 s idle timeout reaps the connection, and the redial’s bind retries across that window instead of failing. Both ends need a qqt that speaks -R; an older server resets the control stream and the client says so (its -l forwards keep working).
4a. Run several clients against one server
One server admits any number of clients, each with its own certificate. The server’s ca-cert.pem is a bundle: every CA in it admits the chains signed by it, so operator-owned and per-customer clients share one door.
gencert mints exactly one client set, so a second machine needs its own identity:
# on the operator: a second client under the same CA
qqt mint --customer laptop --ca-cert ./qqt-certs/ca-cert.pem \
--ca-key ./qqt-certs/ca-key.pem -o ./qqt-certs
cp ./qqt-certs/ca-cert.pem ./qqt-certs/laptop/client/ca-cert.pem
That cp is not optional: a set minted under an operator-owned CA carries only the leaf pair, and without a ca-cert.pem beside it the client cannot verify the server (error: opening cert file …/ca-cert.pem).
Each client runs its own client process against the same -r address, with its own --certs-dir:
# on each machine
qqt client \
-l 127.0.0.1:15432:10.0.0.5:5432 \
-R 127.0.0.1:18080:127.0.0.1:8080 \
-r 203.0.113.10:4433 \
--certs-dir /etc/qqt/client-certs
What is per-client and what is shared:
-llisteners are local to the machine running that client. Two clients on different hosts may bind the same local port without conflict.-Rbinds happen on the server, one per connection, so a server-side port must be unique across clients. The second client asking for a taken port retries for up to ~70 s, then warnsrefused by the serverand keeps its-lforwards running.- Revocation is per-cert: revoking one client’s cert closes that client and leaves the others admitted.
- Metrics count per process. The server’s
conns/handshakesspan all clients; each client’sstreams_totalandreconnectsare its own.
5. Verify
From the client machine:
curl -sS http://127.0.0.1:18080/health
The request rides the QUIC stream to the server, which dials the target. A response is the end-to-end proof; the server log names each dialed target at debug level (-v).
For a reverse forward (§4), the same curl runs on the server box — the bound port lives there — and the request rides a server-opened stream back through the tunnel to the client, which dials the target from its own network position.
If the client prints nothing and hangs, the -r address is wrong or the server’s UDP port is not published: the initial connect has no deadline and no error output. Check the server’s listening on udp line and the platform’s port publish before anything else.
A hung start still stops cleanly: SIGTERM or SIGINT during that connect exits 0 and prints the closing stats line, so a supervisor restarting on failure does not count an operator’s stop as a crash.
5a. Watch the tunnel
--stats prints one stats: line to stderr on an interval (10 s by default, --stats SECS to change it), on either role. It is the zero-infrastructure view: the same numbers the Prometheus endpoint serves, on the stream every other log line already uses, so whatever collects this process’s log collects the stats.
qqt server --listen 0.0.0.0:4433 --certs-dir /etc/qqt/server-certs --stats
# same numbers, pulled instead of printed:
qqt server ... --enable-metrics --stats # both at once
The endpoint is a plain Prometheus target, so a scrape config is the whole setup — no agent, no sidecar, no collector:
scrape_configs:
- job_name: qqt
static_configs:
- targets: ["127.0.0.1:9633"]
curl -s localhost:9633/metrics # the body a scraper reads
curl -s --compressed localhost:9633/metrics # the same, gzipped
Every family carries its # TYPE, so rate() works on the counters and a scraper stores the right class. gzip is offered but not required: the scraper’s own Accept-Encoding decides, and a client that refuses it gets plain text.
A line reads:
16:11:00 UTC stats: role=server remote=0.0.0.0:46100 version=0.8.0 cc=bbr up=38s connected=1 rtt=1.5ms rtt_min=205us jitter=410us cwnd=763.8KiB mtu=1389 bw_tx=1.4KiB bw_rx=524.3KiB tx=797.4KiB rx=792.3KiB tx_pkts=662 rx_pkts=639 sent=663 lost=0 loss=0.00% cong=0 blackholes=0 streams_active=0 streams_total=12 conns=1 handshakes=1
connected=0with the totals still climbing is a reconnect gap, not a reset: the totals are process-lifetime, so a redial adds to them.bw_tx/bw_rxare the last one-second sample, so they fall to0Bthe tick after traffic stops — readtx/rxfor cumulative volume.up,reconnects(client) andconns/handshakes(server) close a window without a second query.- The line at clean exit carries
final=1. A log that ends without one ended on a crash, aSIGKILL, or the client’s contracted loss exit — a client without--reconnectexits 1 the moment the connection dies (§6), and that is normal supervised operation, not a fault. Read the last lines: anerror: connection lostbefore the end is the exit doing its job.
Under systemd, stderr is the journal, so journalctl -u qqt-client -f shows the lines live and they survive a restart. On the rental box’s redirected log (> server.log 2>&1), tail -f server.log is the same view. The design and its rationale — why stderr and not a file or a socket, and why logfmt — are rationale_qqt-stats.md.
6. Supervision semantics
The client exits with status 1 when the connection is lost — deliberately. Loss is detected by the 60 s idle timeout (no received packet for 60 s), so a hard crash costs up to 60 s of black hole before the exit; the shipped unit’s restart pacing takes it from there. Reconnection is a supervisor’s job:
- systemd:
Restart=always,RestartSec=2,StartLimitIntervalSec=0(the shipped examples/qqt-client.service carries all three;StartLimitIntervalSeclives in the[Unit]section on modern systemd). - A cold server (reboot, migration) produces a client that exits and reconnects every 2 s until the server answers.
The server shuts down cleanly on SIGTERM/SIGINT (exit 0) after logging info: shutting down.
7. GPU rental platforms
The pattern qqt was built for. GPU rental platforms give you an unprivileged container — no CAP_NET_ADMIN, so no kernel tunnel interface, no TUN — and relay ssh through an intermediary that adds a full extra round trip to every byte. qqt needs neither: it is userspace-only, and it dials the box’s public IP directly.

The steps below are the general pattern.
Recipe:
- Publish the UDP port at instance creation. The platform only routes ports it was told about. Create the instance with the tunnel port published (e.g.
-p 4433:4433/udp); the platform maps it to a host port, which is what the client’s-rpoints at. - Bake the server into boot. Rental boxes restart without warning. Put a guarded server launch in the platform’s boot hook (
onstart.sh-style) ahead of the workload, and write the file via temp+mv— the running boot shell keeps the old inode of any file it already read. Ship the binary the same way — one stream into a temp file, verify its byte size, thenmvit into place (qqt updoes exactly this): a truncated transfer leaves a partial binary that dies with no clue. - Guard the launch correctly. A process guard must anchor its pattern (
pgrep -f "^/root/qqt server"— the subcommand isserver), because a plain pattern self-matches the launching shell’s own command line — the guard then always “finds” the server and never starts it after a platform restart. - Expect gVisor quirks. On gVisor-sanboxed containers
/proc/net/udpmay not show your socket andssmay be absent — the log’slistening on udpline plus a client handshake are the real proofs. - Keep an ssh -L fallback armed. Run the classic ssh forward as a hot spare (different local port or a stopped unit), and flip the consumers over when QUIC is unavailable (a mid-boot window, a network that eats UDP). The two transports are interchangeable from the consumer’s point of view: both are plain local TCP listeners.
8. Hardening
- Run distinct CAs per trust boundary: a client cert from CA-A never authenticates against a server trusting CA-B. The server’s
ca-cert.pemis a bundle — append a customer’s CA cert to admit them, and keep the operator’s own gencert CA out of a per-customer bundle (then even a stolen operator keyset mints no admitting cert). The bundle is read at server startup, so restart the server after appending — unlike the revocation list, an appended CA admits nobody until you do (instructions_qqt-remint.md §2). - Arm the revocation list:
server --revoked /etc/qqt/revoked.txt(and the same flag in the boot guard) makesqqt revokebite at the next handshake. The list file must not be attacker-writable on the box — whoever can edit it can un-revoke. - The server dials whatever the client names. If certificate holders are less than fully trusted, firewall the server’s egress. A server-side allow-list is a future direction (see the README), not a shipped feature.
- A
-Rbind names where the server listens, so a certificate holder can make the box bind any address and port its process can bind — the same trusted-crew model that lets them name any dial target, mirrored. A bind below 1024 needs the server process to hold the privilege to bind it. - Keys are written
0600and directories0700by construction; do not loosen them to make a copy step easier.