virtuOSo docs v0.8.1

Tailscale on VMs

Overview

When Tailscale is configured in Settings, every VM that virtuOSo creates installs Tailscale on first boot and joins your tailnet with Tailscale SSH enabled. This applies to on-prem and AWS VMs, whether launched from the wizard, the API, a stack or an app. VMs that already exist are not changed.

Setup

Open Settings, then Tailscale.

  • Global mode: one key for everyone. New VMs join the tailnet that key belongs to.
  • Per-user mode: each user saves their own key on their Profile page, and their VMs join their own tailnet.

In global mode you can paste either a regular auth key (tskey-auth-...) or an OAuth client secret (tskey-client-...). Regular auth keys expire after at most 90 days, so they must be replaced regularly; an OAuth client secret does not expire.

OAuth Client Secrets (no key rotation)

  1. In the Tailscale admin console, add the tag you want to use (for example tag:virtuoso) to tagOwners in your access policy.
  2. Create an OAuth client with the Auth Keys: Write scope and that tag. Give virtuOSo its own client rather than sharing one with other tools.
  3. In virtuOSo, paste the client secret into the Auth Key field, enter the same tag under Tags, and choose whether devices are ephemeral.

For each new VM, virtuOSo uses the client secret to request a one-time key that expires after a few hours, and only that one-time key is written into the VM. The client secret stays on the virtuOSo server and is never copied to a VM. The secret is stored encrypted.

  • Tags are required with an OAuth client secret. VMs then join as tagged devices, which are not owned by a user and whose node keys do not expire.
  • Ephemeral devices are removed from your tailnet after they have been offline for a while. Leave this off for long-lived VMs, and delete the device in the Tailscale console when you delete a VM.
  • OAuth client secrets are supported in global mode only.

Hostnames

The device name is built from the account that created the VM:

Created fromHostname
Launch wizard<user>-<vm>
REST API<user>-api-<vm>
Stack<user>-stack-<stack>-<vm>
App<user>-<app>-<instance>
Kubernetes cluster<user>-k8s-<cluster>
MCPmcp-<vm>
If an offline device with the same name is still in your tailnet, Tailscale gives the new VM a -1 suffix. Delete the old device in the Tailscale console, or use ephemeral devices, so rebuilt VMs keep their name.

Tailscale SSH and Access Policy

VMs join with Tailscale SSH enabled, so you can connect with your tailnet identity and no password or key. Tailscale SSH is governed by the ssh section of your access policy. The default rule only covers devices owned by a user (autogroup:self), so tagged VMs need their own rule:

"tagOwners": {
  "tag:virtuoso": ["autogroup:admin"],
},
"ssh": [
  {
    "action": "accept",
    "src":    ["autogroup:member"],
    "dst":    ["tag:virtuoso"],
    "users":  ["autogroup:nonroot", "root"],
  },
],

The VM's page in virtuOSo shows its Tailscale IP and an SSH command once the VM has joined.

Subnet Routes

By default each VM also advertises the subnet it sits on as a Tailscale subnet route, and turns on IP forwarding. The routes need approval in the Tailscale console before they take effect. If you already run a dedicated subnet router, or do not want every VM advertising routes, turn off Advertise each VM's subnet as a Tailscale route under Settings, Tailscale. It applies to VMs created after you save.

Running Commands After Tailscale Connects

Your user_script runs before virtuOSo's Tailscale setup, so it cannot use the tailnet. Use post_tailscale_script for commands that need it, for example registering with another system by tailnet name. It is available on POST /api/v1/vms and in stack VM specs (post-tailscale-script).

  • It runs with bash, once, after Tailscale reports an address. It is installed as a systemd one-shot unit, so a reboot during first boot does not lose it.
  • The environment contains TS_IP and TS_DNSNAME. If Tailscale is not configured, or does not connect within ten minutes, the script runs anyway with them empty.
  • If the script exits with an error it is retried at the next boot, so write it to be safe to run twice.
  • Output goes to /var/log/virtuoso-post-tailscale.log on the VM.
{
  "name": "node1",
  "os": "ubuntu-24.04",
  "post_tailscale_script": "#!/bin/bash\necho \"joined as $TS_DNSNAME ($TS_IP)\" >> /root/joined.txt"
}

Troubleshooting

  • VM did not join: check /var/log/tailscale-setup.log on the VM. If virtuOSo could not obtain a one-time key from an OAuth client, the log says why, and the virtuOSo service log has the full error.
  • Tailscale SSH is refused: the access policy has no ssh rule covering the VM's tag.
  • No Tailscale IP shown for an old VM: virtuOSo looks it up over SSH. Install Tailscale on the VM with tailscale up --ssh, then reload the page.