Networking / User guide
Machine enrollment with trust credentials
Let CI jobs and workloads join the tailnet with OAuth clients or workload identity federation instead of long-lived auth keys.
On this page
Let CI jobs, Kubernetes workloads and other machines join your tailnet on their own, with an OAuth client or with workload identity federation instead of a long-lived auth key.
Before you begin
You need a role that may update the tailnet (admin or owner) to create trust credentials, and a tailnet the organization enrolls into. Decide which tags the machines' nodes carry, for example tag:ci, and make sure your tailnet policy grants that tag what the machines need.
A trust credential comes in two kinds:
- An OAuth client has a secret (
anchras-client-…, shown once). Software exchanges it for a short-lived API token. - A federated identity trusts an external OpenID Connect issuer: GitHub Actions, GitLab CI, a Kubernetes cluster's service accounts, or a cloud's workload identity (AWS, Google Cloud, Azure). An ID token from that issuer whose audience, subject and claims match is exchanged for the same token. Nothing secret is stored.
Both carry scopes and tags. Scopes use Tailscale's names: auth_keys, devices:core, devices:routes, policy_file, dns and all, each also in a :read form. They map to Anchras IAM permissions, and an API token acts as the member who created the credential, capped by those permissions. Tags are the only tags an auth key minted with the credential may carry. The auth_keys (or all) scope requires at least one tag.
Get started
- Open Network → Trust credentials, or use the CLI.
- For a GitHub Actions workflow, create a federated identity for the repository:
anchras tailnets trust-credentials create-federated \
--description "acme/infra deploys" \
--issuer https://token.actions.githubusercontent.com \
--audience anchras \
--subject 'repo:acme/infra:ref:refs/heads/main' \
--scope auth_keys --tag tag:ciNote the client ID it prints. Narrow the subject to the branches or environments that may join (* is a wildcard), and add --claim name=value for further checks such as repository_owner=acme.
- In the workflow, give the job permission to request an ID token, then join an ephemeral node:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Join the tailnet
env:
CONTROL_URL: https://control.example.com # your Anchras control URL
CLIENT_ID: ${{ vars.ANCHRAS_CLIENT_ID }}
run: |
curl -fsSL https://tailscale.com/install.sh | sh
# -E keeps the runner's ID token request variables for the client.
sudo -E tailscale up --login-server="$CONTROL_URL" \
--client-id="$CLIENT_ID" --audience=anchras \
--advertise-tags=tag:ci --hostname="ci-${GITHUB_RUN_ID}"
- name: Reach a private service
run: curl -fsS http://build-cache.your-tailnet.anchras.net/healthzWith --audience, the client fetches the job's ID token from GitHub itself; elsewhere pass one with --id-token (or --id-token=file:<path>, for example a Kubernetes projected service account token). The node is ephemeral and tagged: it leaves the tailnet when the job ends.
- For software without an identity provider, create an OAuth client instead:
anchras tailnets trust-credentials create-oauth-client --scope auth_keys --tag tag:ciStore the secret it prints in your secret manager. The standard client recognizes OAuth secrets by Tailscale's prefix and defaults to Tailscale's API, so wrap the secret and name your control URL:
tailscale up --login-server=https://control.example.com --advertise-tags=tag:ci \
--client-secret='tskey-client-anchras-client-…?baseURL=https://control.example.com'The Anchras client recognizes anchras-client- secrets directly.
- Verify: the node appears in the tailnet's devices with its tag, and the audit log records
tailnet_trust_credential.token_issuedandtailnet_trust_credential.auth_key_mintedfor the credential.
Operate the service
anchras tailnets trust-credentials list shows each credential with its scopes, tags and when it was last used. Keys minted with a credential are single-use, preauthorized as requested, expire within an hour unless the request names an expiry, and carry only the credential's tags.
API tokens live one hour. Delete a credential to revoke it and its tokens at once; auth keys it already minted, and nodes they admitted, stay until you remove them. A credential stops working when the member who created it leaves the organization or loses the right to update the tailnet, so create shared credentials from an account that stays.
Machines exchange credentials at these endpoints, which have the Tailscale API's paths and shapes and answer at your control URL and at the API URL:
POST /api/v2/oauth/token: OAuth client credentials grant.POST /api/v2/oauth/token-exchange: workload identity federation (client_idandjwt).POST /api/v2/tailnet/-/keys: mint an auth key with the API token.
Availability and limits
Trust credentials are in preview. A credential mints only single-use keys, and only tagged ones. An issuer must be served over HTTPS from a public address, and an ID token valid for more than 24 hours is refused. A subject of * alone is refused: on a shared issuer such as GitHub it would trust everyone's workloads, so narrow it or match a claim. Secret-scanning patterns for every Anchras secret format are published in the platform repository (docs/security/secret-scanning-patterns.yml); add them to your scanner as custom patterns.
Troubleshooting
invalid_client: the secret or client ID is unknown, the credential was deleted, or its creator left the organization.invalid_grantwith a subject, claim or audience mismatch: compare the token's claims (decode it) with the federated identity's subject, claims and audience.requested tags … are not all among the credential's tags:--advertise-tagsasks for a tag the credential may not assign.the member who created this credential may no longer enroll devices: create the credential again from a member who may update the tailnet.- The standard client ignored the OAuth secret: it must start with
tskey-client-and carry?baseURL=.
Next steps
Shape what the machines' tag may reach in the tailnet policy, review exchanges in the audit log, and automate credential management with the CLI guide and API guide.
CLI commands
Install and authenticate using the CLI guide. The table describes command families; required arguments are shown in their usage output.
| Command | Purpose |
|---|---|
tailnets trust-credentials list / get <id> | The organization's tailnet trust credentials (ListTrustCredentials, GetTrustCredential, ADA-2160): OAuth clients and federated identities that let machines mint the auth keys they join the tailnet with. get shows the scopes' IAM permissions and a federated identity's issuer, audience, subject and claims. Needs tailnet.read. |
tailnets trust-credentials create-oauth-client --scope <scope>[,…] [--tag tag:<name>[,…]] [--description <text>] | Create an OAuth client (CreateOAuthClient) and print its secret once (anchras-client-<client id>-…; only its hash is stored). Scopes use Tailscale's names (auth_keys, devices:core, devices:routes, policy_file, dns, all and their :read forms) and map to IAM permissions; its API tokens act as you, capped by them. auth_keys (or all) needs at least one --tag: keys it mints carry only those tags. A stock client joins with tailscale up --advertise-tags=tag:ci --client-secret='tskey-client-<secret>?baseURL=<control URL>'. Needs tailnet.update. |
tailnets trust-credentials create-federated --issuer <url> --audience <aud> --subject <pattern> --scope <scope>[,…] [--tag …] [--claim name=value]… | Create a federated identity (CreateFederatedIdentity, workload identity federation): an ID token from --issuer (https; GitHub Actions, GitLab, a Kubernetes cluster, AWS, GCP, Azure) for --audience whose subject and --claims match (* is a wildcard; a bare * subject needs a claim) is exchanged for an API token. Prints the client ID for tailscale up --client-id=<id> --id-token=<token> (or --audience=<aud>). Needs tailnet.update. |
tailnets trust-credentials delete <id> | Delete a credential (DeleteTrustCredential); its API tokens are revoked with it. Auth keys it already minted, and the nodes they admitted, stay. Needs tailnet.update. |
API reference
Browse procedures, request and response types, and download the complete OpenAPI contract.
