Migrating to sessions and API keys
Starting with version 0.39, tuna-cli signs into your account using a device session instead of a token. For servers, CI, and anything that runs unattended, an API key replaces the token. Old tokens continue to work but are deprecated.
What changed
Previously, an account had a single tt_… token shared across all devices. tuna login saved it to a config file, and the same token was copied into CI, Docker, and services. Revoking access for a single device was impossible: reissuing the token broke tunnels everywhere.
Now access is split:
| Where | Signs in with | Stored in |
|---|---|---|
| CLI on a laptop | device session | system keychain |
| Tuna Desktop 0.3+ | device session or API key | system keychain or local app database |
| Server without a browser | session confirmed via a link from another device, or API key | keychain or config file |
| CI, Docker, Kubernetes, Terraform | API key | TUNA_API_KEY variable or CI secret |
Background service tuna service | dedicated service key | file accessible only to the service user |
What this gives you:
- Each device is a separate session. The list of sessions is available in your profile and via
tuna session list. If a laptop is lost, terminate its session: that device's tunnels will stop immediately while the rest keep running. - A session cannot be silently copied. A session stores a short-lived access token and a refresh token that changes on every refresh. If someone tries to reuse an old refresh token, the server terminates the entire session.
- One key per task. For CI, a server, or a colleague you can issue a separate API key with the required permissions and delete it without affecting the others.
Sessions have no hard expiration. A session is terminated if the device has not used it for 30 days. A running tunnel extends the session automatically.
What happens to the old token
Nothing will break. All tt_… tokens have been migrated to API keys with the tunnel launch permission (tunnels:connect): they start tunnels as before and, as before, do not access the API. Older CLI and Tuna Desktop versions continue to work.
The new CLI accepts the old token but warns about the replacement:
- environment variable
TUNA_TOKEN→ useTUNA_API_KEY; - flag
--token→--api-key; - field
tokenin the config file → sign in withtuna loginor store an API key; - command
tuna config save-token→tuna login --with-api-key.
There is no shutdown date for old tokens yet. We will give advance notice when we decide on one.
New accounts no longer receive a token at registration: the token page in the dashboard has been replaced with the API keys page.
How to migrate
Laptop
Sign in again:
tuna login
A browser will open; after confirmation the CLI stores the session in the system keychain: Keychain on macOS, Credential Manager on Windows, Secret Service on Linux. If no keychain is available, add --insecure-storage: the session will be saved to a credentials.json file next to the config file.
To make the device easy to identify in the session list, give it a name:
tuna login --hostname=work-laptop
After signing in you can remove the old token from the config file: tuna logout terminates the session and asks whether to delete the stored key. If background services rely on this key, reinstall them first.
Tuna Desktop uses sessions starting with version 0.3. Older versions and token-based sign-in continue to work: to switch to a session, update Desktop, sign out, and sign back in.
Server without a browser
If you access the server via SSH, sign in with a link:
tuna login --no-browser
The CLI will display a link and a code. Open the link on any device where you are signed in to the dashboard and verify the code matches. The CLI automatically detects an SSH session and suggests this method first.
The session on a server is tied to your account. If the server is shared by the team or tunnels should keep running after you leave, use an API key as you would for CI.
CI, Docker, and scripts
- Create an API key. Select the "For tunnels" preset or enable "Launch tunnels": without the
tunnels:connectpermission the key cannot start tunnels. - Store the key in CI secrets or the container environment as
TUNA_API_KEYinstead ofTUNA_TOKEN.
export TUNA_API_KEY=<your_key>
tuna http 8080 -s=myapp
In Docker Compose:
services:
tuna:
image: yuccastream/tuna:latest
command: http web:80 -s=myapp --inspect=false
environment:
- TUNA_API_KEY=<your_key>
To save the key on a machine so you don't have to pass it every time, use tuna login --with-api-key. It reads the key from stdin, so it won't appear in shell history:
echo "$TUNA_API_KEY" | tuna login --with-api-key
If the key lacks the tunnel permission, the CLI will warn about it on sign-in.
Background services
Services installed by the old CLI run with the old token and will continue to work. To switch a service to its own key, sign in with tuna login and reinstall it with the same command. The old CLI created system services on Linux and FreeBSD, so remove them with sudo; on Windows, use an Administrator PowerShell:
tuna service list
sudo tuna service uninstall --name=web
tuna service install --name=web -- tuna http 8080 -s=web
Without sudo, the new CLI on Linux creates a user-level systemd --user service. If you need a system-level service, run install with sudo: root cannot see your session, so the CLI will ask you to confirm key issuance via a link.
install issues a key scoped to this service and binds it to the tunnel type and address if the command includes --subdomain, --domain, or --port. uninstall revokes the key. For details, see Running in the background.
Terraform and Kubernetes operator
The Terraform provider and the Kubernetes operator have always used API keys: api_key or TUNA_API_KEY for the provider, credentials.apiKey for the operator. No changes are needed.
FAQ
Will my CI with TUNA_TOKEN stop working after the update?
No. The new CLI accepts TUNA_TOKEN and only logs a warning. Rename the variable to TUNA_API_KEY at your convenience: the same value will work since the old token has already been migrated to an API key.
Where do I get a token if the dashboard no longer shows one?
You don't need a token for your own computer: sign in with tuna login. For CI and servers, create an API key with the tunnel launch permission.
How do I verify the CLI is no longer using the old token?
tuna whoami
This command shows the account. If the CLI is still picking up the TUNA_TOKEN variable or the token field from the config file, it will warn about it.
How do I sign out on one device without affecting the others?
Run tuna logout on the device itself. If you don't have access to the device, terminate its session in your profile: the device's tunnels will stop immediately and the CLI will exit.
What happens to services after tuna logout?
Services installed by the new CLI run on their own keys; tuna logout does not affect them. Services using the old token or a key from the config file will stop working if you delete that key — that's why logout asks whether to delete it. Without a terminal the key remains; you can delete it with the --yes flag.
There is no keychain on the system. What do I do?
Servers without a graphical session often lack a keychain. Sign in with --insecure-storage to save the session to a file, or use an API key.