From a simple browser login to creating short-lived, user-owned machines with one click.

I've been using Tailscale for years, and quite a bit more since joining Tailscale earlier this year. For most of that time, getting a device onto my tailnet was simple: install Tailscale, sign in through a browser, done.

But what if the device isn't your laptop? Maybe it's a CI runner, a hundred servers, or a disposable sandbox someone just created through a web portal.

That last one is what got me experimenting. I built a little Firecracker demo where you click Create sandbox, approve a Tailscale prompt, and a few seconds later a fresh VM joins your tailnet as your device, marked as a sandbox so you can give it different access than your laptop. No auth keys to copy around, and no Tailscale credentials inside the VM. When you're done, you destroy it and the ephemeral device disappears too.

It turns out there are quite a few ways to authenticate a Tailscale client, from the obvious to some surprisingly clever ones. I figured it'd be useful to write down all(?) five of them, how they work, and when you might use each.

We'll start with the familiar stuff and work our way toward that sandbox demo. Let's dive in!

First, what does authenticating a device actually mean?

Before looking at the different methods, let's quickly cover what happens when a device joins a tailnet.

Tailscale uses WireGuard for encrypted connections between devices. Each device generates a WireGuard key pair. The private key stays on the device, while the public key can be shared with other devices it is allowed to communicate with.

But before Tailscale can register a new device, it needs to establish its identity.
In simplified terms:

  1. The Tailscale client generates its cryptographic keys.
  2. The client authenticates with Tailscale's coordination service.
  3. Tailscale associates the device with an identity on your tailnet.
  4. Based on your access policies, other devices can learn about it and establish encrypted connections.

The interesting part for this post is step two: How does the client prove it's allowed to join?

There's another important distinction worth understanding upfront. A device can belong to either a user or a tag.

A user-owned device might belong to alice@example.com. It gets access based on Alice's identity and whatever policies apply to her.

A tagged device might belong to tag:server or tag:ci. Tags are identities for machines and services rather than people. I think of them as service accounts, making them particularly useful for infrastructure that shouldn't depend on an individual employee's account.
Keep that distinction in mind. It'll come up again.

1. Interactive login: the one everyone knows

This is where most of us started. Install Tailscale and run:

sudo tailscale up

You'll get something like:

To authenticate, visit:

https://login.tailscale.com/a/1f3c9a7b2d4e

Open the URL, sign in using your identity provider (Google, Microsoft, Okta, GitHub, etc.), and your device joins the tailnet.  On macOS, Windows, or mobile, it's essentially the same process, just with a login button instead of a terminal command.

The device becomes associated with the user who signed in.
For personal devices like laptops, desktops, and phones, this is generally exactly what you want.
Simple enough. But it requires a person to authenticate when registering a new device. That's fine for a laptop, less convenient when you're launching a hundred servers or creating temporary machines automatically.

So how do we take the human out of the process?

2. Auth keys: authenticate without a browser

The next option is probably familiar to anyone who has automated Tailscale deployments.
Instead of authenticating interactively, you generate an auth key ahead of time. You can create one in the Tailscale admin console under Keys, or through the API.
Then:

sudo tailscale up --auth-key=tskey-auth-...

That's it. No browser, no user interaction.
Auth keys are useful for cloud-init, containers, server deployments, and CI/CD systems.

There are a few options worth knowing about:

  • One-off or reusable: A one-off key registers one device. A reusable key can register multiple devices.
  • Ephemeral: Useful for temporary workloads. The device is automatically removed after it goes offline.
  • Pre-approved: Skips manual device approval, if your tailnet requires it.
  • Tagged: Registers the device with a tag such as tag:server instead of an individual user.

That last option is particularly useful. Without a tag, a device registered using an auth key belongs to the user who created the key. With a tag, it belongs to the tag instead. There's one limitation, though.

Auth keys expire after at most 90 days.

That doesn't mean devices already registered with the key suddenly disconnect. It just means the key can no longer register new devices. Existing devices follow their own node-key expiration rules.

For a one-time deployment, that's probably fine. But if you're continuously bringing up new machines, rotating auth keys every few months gets a little annoying. Fortunately, there's another way.

3. OAuth clients: long-lived credentials for automation

Tailscale also supports OAuth clients, essentially service credentials that can authenticate to the Tailscale API. You create one under Trust credentials in the admin console, and Tailscale gives you:

  • A client ID, identifying the OAuth client.
  • A client secret, which your automation needs to keep secure.

You also configure its permissions, or scopes. To register devices, you need the auth_keys scope and permission to use one or more tags, such as tag:ci.

You could use the OAuth client to call the Tailscale API, generate an auth key, and pass that key to your device.

But here's a neat shortcut: you can pass the OAuth client secret directly to tailscale up.

sudo tailscale up \
  --auth-key="$OAUTH_CLIENT_SECRET" \
  --advertise-tags=tag:ci

Here, OAUTH_CLIENT_SECRET is the secret you received when creating the OAuth client. Tailscale handles obtaining an auth key behind the scenes and registers the device. Pretty convenient!

There's another interesting detail: devices registered this way are ephemeral by default. Great for short-lived CI runners, but perhaps not what you want for a permanent server.
You can change that by appending a couple of parameters:

sudo tailscale up \
  --auth-key="${OAUTH_CLIENT_SECRET}?ephemeral=false&preauthorized=true" \
  --advertise-tags=tag:ci

Now we're creating a non-ephemeral device and asking Tailscale to skip manual device approval.

Unlike regular auth keys, OAuth client secrets don't have that same 90-day expiration limit. Your automation can keep registering devices without replacing the auth key every few months.

One important restriction: devices registered using OAuth clients are always tag-owned.
That makes sense. We're authenticating a service, not a person.

For automated infrastructure, this is a great solution. But we still have a long-lived secret sitting somewhere, probably in a secret manager or CI environment.
Wouldn't it be nice if we could get rid of that secret entirely? Well, we can :)

4. Workload identity federation: authenticate without storing secrets

This is one of my favorite options. The idea behind workload identity federation is pretty simple. Many cloud and CI environments already provide a way for workloads to prove their identity.

For example, a GitHub Actions job can obtain a signed OpenID Connect (OIDC) token from GitHub. That token can contain information about which repository, branch, or workflow is running, who issued the token, and who it's intended for.

In other words, GitHub can already prove that a particular workload is running. So rather than giving that workload a Tailscale secret, why not let it use the identity it already has? That's exactly what workload identity federation does.

Setting it up

First, we tell Tailscale which identity provider and workloads to trust. In the Tailscale admin console, go to Trust credentials, create a new credential, and select OpenID Connect.

For a GitHub Actions example, we'd configure something like:

  • Issuer: https://token.actions.githubusercontent.com
  • Subject: repo:acme/app:*
  • Scope: auth_keys, with permission to use tag:ci

The issuer identifies who's signing the token. The subject specifies which workloads we'll accept. In this example, we're matching workflows from the acme/app repository.

You can add more specific claim restrictions too, for example to limit access to particular branches or environments. Once you've created the credential, Tailscale gives you a Client ID and an Audience value.

These two values are worth explaining.

The Client ID identifies the federated identity configuration you just created in Tailscale. It's not a GitHub OAuth client ID, and it's not a secret.

The Audience tells the identity provider who the token is intended for. Tailscale verifies that the token was issued for this trust relationship.

Now the client can authenticate like this:

sudo tailscale up \
  --client-id="$CLIENT_ID" \
  --audience="$AUDIENCE" \
  --advertise-tags=tag:ci

Both variables come from the Tailscale configuration we just created.  On supported platforms, including GitHub Actions, AWS, and GCP, recent Tailscale clients can automatically request the identity token from the environment.
You can also obtain the token yourself and pass it explicitly:

sudo tailscale up \
  --client-id="$CLIENT_ID" \
  --id-token="$ID_TOKEN" \
  --advertise-tags=tag:ci

Here, ID_TOKEN is the short-lived, signed OIDC token issued by the platform running your workload. Tailscale validates the token's signature, issuer, audience, and configured claims before allowing the device to join. And that's it.

No long-lived Tailscale secret to distribute or rotate.

The workload gets its identity from the platform it's already running on. Tokens are short-lived, and your trust configuration determines which workloads are allowed to authenticate.

I really like this approach. It removes an entire class of credential-management problems. Like OAuth clients, these devices are tag-owned.
So far, we've covered some good options for infrastructure. But there's one interesting use case we haven't solved.

What if we want to automatically create a device that belongs to an actual person?

5. OAuth apps: create devices on behalf of users

This is probably the most interesting option of the five, at least for what I've been playing with recently.

Imagine you're building an internal developer portal. A developer visits a web page, clicks Create sandbox, and a few seconds later a fresh virtual machine is running.

Now imagine we want that sandbox to join the developer's tailnet automatically. Not as tag:sandbox, but as a device that actually belongs to the developer.

If Alice creates a sandbox, we want it associated with Alice's identity and subject to her access policies. If Bob creates one, it should belong to Bob.

We could ask each developer to create an auth key and paste it into our portal. But that's not a great experience, and collecting users' auth keys isn't something I'd want to build into a service.

This is where Tailscale OAuth apps come in. Despite the similar names, OAuth apps and the OAuth clients we discussed earlier solve different problems.

OAuth clients authenticate services and create tag-owned devices. OAuth apps let users authorize an application to create devices on their behalf.
The result is a user-owned device, without the user ever having to generate or share an auth key.

How it works

The process uses a standard OAuth authorization code flow, much like the familiar "Sign in with..." experience.
For our sandbox portal, it looks like this:

  1. Alice visits the portal and clicks Create sandbox.
  2. The portal redirects her to Tailscale, asking permission to add a device on her behalf.
  3. Alice signs in if necessary and approves the request.
  4. Tailscale redirects her back with a temporary authorization code.
  5. The portal exchanges that code for a single-use access token.
  6. The portal uses that token to register the sandbox device.

The really neat part is step five. The access token returned by Tailscale can be used directly as an auth key:

sudo tailscale up --auth-key="$ONE_TIME_TOKEN"

The token is valid for one hour and can only be used once. The resulting device belongs to Alice, the person who approved the request.

To set this up, a tailnet admin creates an OAuth app through the API, registers a callback URL, and grants it the auth_keys:create:once scope.

The portal keeps its own OAuth app client secret securely on the server to exchange authorization codes. But it never needs Alice's personal credentials or a reusable auth key belonging to her.

Each new device requires fresh user consent, and this flow works within a single tailnet. For an internal developer portal, that's a pretty nice model.

One more neat trick: device posture attributes

There's another feature of this flow that I particularly like. Remember how the sandbox belongs to Alice?

That's great, but how do we distinguish Alice's laptop from a sandbox created on her behalf?

Both belong to Alice, but they're clearly not the same kind of machine. Her laptop might be a trusted, company-managed device. Her sandbox could be a temporary VM running all sorts of experimental code. We probably don't want to give them exactly the same access.

Fortunately, OAuth apps can automatically assign custom device posture attributes when provisioning devices. For example, when creating our OAuth app, we can allow it to assign an attribute called custom:sandbox.

In the API request that creates the app, we'd include:

"allowedNodeAttributes": ["custom:sandbox"]

Then, when the portal exchanges Alice's authorization code for a token, it can attach that attribute. Here's an example of the token request I used:

curl -X POST https://api.tailscale.com/api/v2/oauth/token \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  -d redirect_uri="$REDIRECT_URI" \
  -d ephemeral=true \
  --data-urlencode 'node_attributes={"custom:sandbox":true}'

The CLIENT_ID and CLIENT_SECRET here are the credentials of the OAuth app, rather than the federated identity from the previous section.

Notice two interesting things in this request. First, we're attaching custom:sandbox to the device.

The sandbox still belongs to Alice, but now we know it's Alice's sandbox, not Alice's laptop.

Because these are device posture attributes, we can use them in Tailscale's access policies. For example, we could configure policies that allow Alice's regular laptop to access production infrastructure while restricting what her sandbox can reach.

This is different from assigning a Tailscale tag. Tags replace the user identity for access control purposes. Device posture attributes let us preserve the user's identity while also describing what kind of device it is.

That's a pretty useful combination. We get user-level identity and attribution without treating every device belonging to that user as equally trusted.

The second interesting thing in that API request is ephemeral=true.
Yes, OAuth app provisioning supports ephemeral devices too!

I tested this with my sandbox setup, and it works. The sandbox joins as Alice's device, carries the custom posture attribute, and is registered as ephemeral. That makes it a particularly good fit for temporary development environments.

A little Firecracker sandbox demo

I liked this approach enough that I built a small demo using Firecracker.

In the video below, I pick a sandbox size, leave Put it on my tailnet checked, and click Create sandbox. Tailscale asks me to authorize the portal to add a device on my behalf. A few seconds later, the Firecracker VM has booted and the new device shows up in my tailnet.

I open the sandbox's terminal, check connectivity, and reach another service on my tailnet. Then I destroy the sandbox and confirm that its device disappears from the Tailscale admin console.

Demo: Creating a Firecracker sandbox, connecting it to my tailnet, and cleaning it up

There's one implementation detail I particularly like. Tailscale doesn't actually run inside the Firecracker VM.

Instead, I run it on the host, alongside the VM. The sandbox uses that host-side Tailscale connection. That way, the one-time authentication token never enters the guest VM. Whatever runs inside the sandbox can use the tailnet connection, but it doesn't get access to the Tailscale credentials or control over the Tailscale client.

For disposable, potentially untrusted development environments, that's a nice separation. And because we're using an ephemeral device, cleanup is easier too. Once the corresponding Tailscale instance goes offline, its device registration is automatically removed from the tailnet, normally within 30–60 minutes. You can also use tailscale logout to remove it immediately.No more abandoned sandbox devices piling up in the admin console :)

For developer tooling and temporary workspaces, I think this is a pretty neat pattern: on-demand infrastructure that belongs to the right user, connected to the tailnet without giving the sandbox their Tailscale credentials. Pretty cool!

For more implementation details, check out the Tailscale documentation on device provisioning with OAuth apps.

So which method should you use?

Here's a quick summary of the five options.

I think the easiest way to choose is to start with one question: Who should own the device?

For personal devices, interactive login is the obvious choice. For servers, CI runners, and other automated infrastructure, tagged devices generally make more sense.

If you're automating those deployments, auth keys work fine for simple use cases. OAuth clients avoid the 90-day auth key rotation problem, and workload identity federation is particularly attractive when your environment supports it, since you don't have to manage long-lived Tailscale credentials.

And if you're building something that creates devices on behalf of users, OAuth apps offer a really interesting option.

There are also plenty of integrations that simplify these methods, including the Tailscale GitHub Action, Kubernetes operator, Docker integration, Terraform provider, and various MDM solutions.

What I find interesting is how far we've come from the original browser login. The underlying goal is still the same, getting a device onto your tailnet with the right identity, but there are now some pretty clever ways to accomplish that.

I've especially enjoyed experimenting with the OAuth app flow. Being able to create a temporary sandbox, associate it with a real user, and attach device posture attributes opens up some interesting possibilities.

If you're building something fun with any of these approaches, I'd love to hear about it. That's it. You made it to the end :) Thanks for reading!

Cheers,
Andree