A HashiCorp Vault plugin for generating device authentication keys for Tailscale. Generated keys are single use.
- Download the binary for your architecture from the releases page
- Generate the SHA256 sum of the plugin binary
SHASUM=$(sha256sum vault-plugin-tailscale | cut -d ' ' -f1)
- Add the plugin to your Vault plugin catalog (requires VAULT_TOKEN to be set)
vault plugin register -sha256="${SHASUM}" secret vault-plugin-tailscale
- Mount the plugin
vault secrets enable -path=tailscale vault-plugin-tailscale
- The ID of your tailnet is displayed on the top left of your admin console (your org name)
- Obtain an API key or Oauth client credentials ("devices" scope) from the Tailscale admin dashboard.
- Create the Vault configuration for the Tailscale API
# Authenticate through an API Key
vault write tailscale/config \
tailnet="${TAILNET}" \
api_key="${API_KEY}"
# Or use oauth client credentials
# Make sure to change the api_url!
vault write tailscale/config \
tailnet="${TAILNET}" \
oauth_client_id="${OAUTH_CLIENT_ID}" \
oauth_client_secret="${OAUTH_CLIENT_SECRET}" \
api_url='https://api.tailscale.com/api/v2/oauth/token'
Generate keys using the Vault CLI.
vault read tailscale/key
This will yield the following output:
Key Value
--- -----
ephemeral false
expires 2024-08-30T00:00:00Z
id kMxzN47CNTRL
key ....
reusable false
tags
The following key/value pairs can be added to the end of the vault read
command to configure key properties:
A comma separated list of tags to apply to the device that uses the authentication key. Keys must have a tag set. You can assign default tags to an oauth client on credential creation though.
vault read tailscale/key tags='tag:foo,tag:bar'
If true, machines added to the tailnet with this key will not required authorization.
vault read tailscale/key preauthorized=true
If true, nodes created with this key will be removed after a period of inactivity or when they disconnect from the Tailnet.
vault read tailscale/key ephemeral=true
If true, the key can be reused for different nodes/devices. This is useful if you're dealing with ephemeral VMs or pods.
vault read tailscale/key reusable=true
By default the lifetime of a generated key is 90d
. You can set a shorter liftime if needed.
Durations can be set using the standard golang duration notation.
vault read tailscale/key lifetime='24h'