tailscalekit
A small, dependency-free toolkit for putting machines you don't fully trust (GPU pods, CI runners, containers) on your Tailscale tailnet, then cleaning them up. It works from Python, Bash and the command line, and it is the sibling of runpodkit.
- Mint safe auth keys: single-use, pre-approved, short-lived (15 min by default), ephemeral or tagged.
- Join a container:
pod/bootstrap.shruns tailscaled in userspace mode (no TUN device). The key goes to tailscale through a 0600 file, never argv, and is never printed. - Find, wait for, and remove devices by hostname. Tailscale's
-1duplicate suffixes are handled. - Verify revocation properly. The API keeps revoked keys readable (HTTP 200 with
"invalid": true), so tailscalekit checks the flag, not the status code. - Check your policy for the default allow-everything ACL before you expose a service.
Install
pipx install tailscalekit # CLI
python3 -m pip install tailscalekit # library, inside a venv
For development, clone it and run ./install.sh python3, which links the clone into an interpreter so git pull updates every user on the host. That link carries no package metadata, so a package that declares tailscalekit as a dependency should use the pip install above.
Credentials
tailscalekit reads credentials from the environment only. There are no key flags, so a credential never lands in argv or shell history.
| Variables | Use |
|---|---|
TS_OAUTH_CLIENT_ID + TS_OAUTH_CLIENT_SECRET |
Recommended. An OAuth client scoped to auth_keys (write) and devices:core (read/write), plus policy_file (read) for policy-check. It doesn't expire and can only do what you scoped. Keys minted with it must carry a tag. |
TS_API_KEY |
A personal API key (tskey-api-…). Simpler, but it is full-admin and expires within 90 days. |
TS_TAILNET |
Tailnet name; defaults to - (the credential's own tailnet). |
Letting an AI coding agent drive this? Store the credential in cred-broker and run cred exec tailscale -- tailscalekit …. The agent uses the credential without ever seeing it.
Quick start
Put a container on the tailnet
# on your machine: mint a single-use key for one container (expires in 15 minutes)
KEY=$(tailscalekit authkey --tag tag:llm-starter)
# in the container (image with curl; static tailscale is downloaded and sha256-checked if missing)
TS_AUTHKEY="$KEY" TS_HOSTNAME=llm-pod1 bash "$(tailscalekit pod-bootstrap)"
# TAILSCALEKIT TAILNET_UP ip=100.x.y.z hostname=llm-pod1
# back on your machine
tailscalekit wait-online llm-pod1 # prints the tailnet IP once it is connected
tailscalekit delete llm-pod1 # when you're done
Python
from tailscalekit import Tailscale, device_ip
ts = Tailscale() # env credentials
key = ts.create_auth_key(tags=["tag:llm-starter"], expiry_seconds=600)
# … hand key["key"] to the machine (e.g. as a pod environment variable) …
device = ts.wait_online("llm-pod1", timeout=300)
print(device_ip(device))
ts.revoke_key(key["id"]); assert ts.key_revoked(key["id"])
Bash
. "$(tailscalekit bash-lib)"
ip=$(ts_wait_online llm-pod1 300) && curl "http://$ip:11434/api/tags"
ts_delete llm-pod1
Lock it down: the tailnet policy
The default Tailscale policy lets every device reach every other device. If the machine you add runs a service with no authentication of its own (an Ollama server, a Jupyter kernel), anyone on the tailnet can use it. And if that machine is compromised, it can reach your laptop and NAS. tailscalekit policy-check prints default-allow when that is the case. A minimal policy for one tagged service:
{
"tagOwners": { "tag:llm-starter": ["autogroup:admin"] },
"grants": [
// your own devices may reach the service port on tagged machines…
{ "src": ["autogroup:member"], "dst": ["tag:llm-starter"], "ip": ["tcp:11434"] }
// …and nothing is granted FROM tag:llm-starter, so the pod can't reach your devices.
]
}
Merge this into your existing policy rather than replacing it. Minting a tagged key fails with HTTP 400 ("not permitted") until the minting identity owns the tag.
Reference
Python (tailscalekit.Tailscale)
| Method | Result |
|---|---|
list_devices() |
All devices (dicts) |
find_device(hostname, created_after=None, tag=None) |
Newest exact match (then hostname-N duplicates), or None |
get_device(id) / delete_device(id) |
Device or None on 404 / HTTP status (404 = already gone) |
create_auth_key(reusable=False, ephemeral=True, preauthorized=True, tags=None, expiry_seconds=900, description="tailscalekit") |
{"id", "key", "expires", …}; the only copy of the key |
list_keys() / get_key(id) |
Key metadata, never values |
revoke_key(id) / key_revoked(id) |
HTTP status / True once the key is unusable |
get_policy() |
The tailnet policy as JSON |
wait_online(hostname, timeout=240, poll=5, created_after=None, tag=None) |
The device once connectedToControl with an IP; retries transport errors, 429 and 5xx; raises TailscaleTimeoutError |
Helpers: device_ip(device, version=4), public_device(device) (drops node, machine and lock keys), policy_allows_all(policy), redact(text, *secrets) (removes every tskey-…).
CLI
| Command | Output | Exit |
|---|---|---|
devices [--all-fields] |
JSON; node, machine and lock keys hidden by default | 0 |
device HOST|ID [--all-fields] |
Device JSON | 0, or 3 if not found |
ip HOST|ID [--ipv6] |
Tailnet IP | 0, or 3 if not found |
authkey [--tag T]… [--reusable] [--no-ephemeral] [--no-preauthorized] [--expiry S] [--description D] [--json] |
The key, or {"id","key","expires"} |
0 |
keys |
Key metadata JSON | 0 |
revoke KEYID |
HTTP status; then verifies the key is invalid | 0, or 1 if still valid |
delete HOST|ID |
HTTP status | 0, or 3 if not found |
wait-online HOST [--timeout N] [--after ISO] [--tag T] [--json] |
IP or device JSON | 0, or 3 on timeout |
policy-check |
default-allow or restricted |
0 |
bash-lib / pod-bootstrap / version / --version |
Path / path / version | 0 |
All commands also use 1 for errors (one tailscalekit: line on stderr, secrets redacted), 2 for usage errors, and 130 on Ctrl-C.
Bash library
ts_authkey [flags], ts_ip HOST, ts_wait_online HOST [TIMEOUT], ts_delete HOST (an already-missing device counts as success), ts_revoke KEYID. Credentials are exported only inside the CLI's subshell. The library is safe under set -uo pipefail and works on Bash 3.2.
Pod bootstrap (tailscalekit pod-bootstrap)
| Variable | Default | Meaning |
|---|---|---|
TS_AUTHKEY |
– | Used only if the node isn't already authenticated; unset immediately and passed via a 0600 file |
TS_HOSTNAME |
$RUNPOD_POD_ID, else hostname |
Tailnet hostname |
TS_STATE_DIR |
/workspace/tailscale |
Keep it on a persistent volume so a restarted container rejoins without a new key |
TS_VERSION |
1.104.7 |
Static build to install if tailscale is missing (sha256-pinned for amd64) |
Ephemeral vs. tagged: an ephemeral node vanishes shortly after it goes offline, which suits throwaway runs. A tagged, non-ephemeral node (--no-ephemeral --tag …) keeps its identity across stop/start through the saved state, and tagged devices don't hit key expiry. Delete it explicitly when you're done.
Security notes
- Keys come from the environment only. Error output redacts the configured secret and any
tskey-…token. - A key given to a machine should be assumed readable by whoever controls that machine's platform. Single-use, short expiry and revoke-after-join keep the blast radius small.
authkeyprints the minted key, on purpose: piping it to a machine is its job.- Tests are offline; every unmocked network call fails the test.
Development
python3 -m unittest discover -s tests -v
TAILSCALEKIT_TEST_BASHES=/path/to/bash3.2:/bin/bash python3 -m unittest tests.test_bash -v
License
MIT. See LICENSE. Not affiliated with or endorsed by Tailscale Inc.
Metadata
Release files for tailscalekit 0.1.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 |
|---|---|---|---|---|
| tailscalekit-0.1.0.tar.gz | 37.6 kB | With provenance | Details for tailscalekit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tailscalekit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tailscalekit-0.1.0-py3-none-any.whl |
Total release size: 56.6 kB
Release files / tailscalekit-0.1.0.tar.gz
| Download URL | tailscalekit-0.1.0.tar.gz |
|---|---|
| Size | 37.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a836bd6b512aa8afa54179de18623599d155f862643ff8ccbf3779266a4ca07e
|
|
BLAKE2b-256 checksum How to use checksums |
a29d04963afac54d9cbea53b761d9a46a51e5392404d8fcb3951aaa27a1cd943
|
| 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 Dec 2, 2026.
Transparency logRelease files / tailscalekit-0.1.0-py3-none-any.whl
| Download URL | tailscalekit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5068eb10a73fc0678b32eed19103046d4d46240aaa6bd3bfef678384d8ebf23c
|
|
BLAKE2b-256 checksum How to use checksums |
7af2279dfe6a3f6115e17cc3743c77b17513964e4e47452c85173214d25cb8f3
|
| 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 Dec 2, 2026.
Transparency logSecurity for tailscalekit 0.1.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 tailscalekit-0.1.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 Dec 2, 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.