Guide · Tailscale handoff
Enter an API key from your phone over Tailscale
A local Keyrelay link opens only on the computer running the command. When your agent runs on a desktop or home server and you're somewhere else, run a private Keyrelay broker on your Tailnet and type the key on your phone.
Who this suits
A good fit
- You already use Tailscale, and your phone and the agent's machine are on the same Tailnet.
- You leave a coding agent working and check in from another device.
- You can keep a small always-on process running on a machine you trust.
Stay with local mode
- You're at the computer running the agent. Local mode needs no setup at all.
- You don't use Tailscale, or other people sign in to your Tailnet as you.
- The only way to reach the broker would be the public internet. Don't do that.
What you need
- Tailscale on your phone and on the machine that will run the broker, with HTTPS certificates enabled for your Tailnet so Tailscale Serve can serve HTTPS.
- Python 3.9 or newer on the broker machine, and Node.js 18 or newer wherever you use
npx. - The machine running the agent must reach the broker's HTTPS address. The broker can run on that same machine or on another one in your Tailnet.
Set it up
All names below are examples. Use your own Tailscale login and your machine's Tailnet name.
1. Start the broker
npx keyrelay serve --email you@example.com --host your-broker.your-tailnet.ts.net
tailscale serve --bg http://127.0.0.1:8765
The broker listens on 127.0.0.1:8765 only. Tailscale Serve puts it on your Tailnet over HTTPS and tells it who is signed in.
2. Point the runner at it
npx keyrelay run --url https://your-broker.your-tailnet.ts.net --env DEMO_TOKEN -- printenv DEMO_TOKEN
Open the printed link on your phone, type a made-up value, and send it. The command runs on the agent's machine and prints [REDACTED].
3. Tell your agent
Use the same instruction as local mode, with --url https://your-broker.your-tailnet.ts.net added to the command pattern.
To keep the broker running on Linux, the repository ships a systemd unit. The usage reference has the install commands.
What the broker checks
- The exact host. A request is refused unless its
Hostheader matches--hostexactly. - Your Tailscale identity. Tailscale Serve adds a
Tailscale-User-Loginheader, and the broker refuses any other login than--email. - HTTPS only. The runner refuses a
--urlthat isn'thttps://. - Same-origin posts. The form rejects submissions from other web origins.
- A separate claim token. The link lets you view the form and submit once. Only the runner that created the request holds the token to collect the key, so opening the link can't retrieve it.
Rules that keep it private
- Never expose the broker with Tailscale Funnel or a public reverse proxy. The identity check assumes only Tailscale Serve can reach it.
- Keep it bound to localhost. Any process on the broker machine can still connect to that port directly and claim to be you, so run the broker on a machine you trust.
- Treat your Tailnet login as the key to the form. Any device signed in as the allowed user can open a pending link.
How it differs from local mode
- The key travels from your phone to the broker and on to the runner over HTTPS. It still goes only to the command on the machine running
keyrelay run. - The broker keeps waiting requests in memory, never on disk, and doesn't log requests. Restarting it discards them.
- If you cancel the runner, its request stays on the broker until it expires five minutes after it was created, and is removed on the broker's next request after that.
- A broker accepts at most 100 waiting requests at a time.