Skip to main content

Session sign-in and API keys instead of a token

· 4 min

Until now, an account had a single token for all devices. tuna login saved it to a config file, and the same token was copied into CI, Docker, and background services. Revoking access for a single laptop was impossible: reissuing the token broke tunnels everywhere.

In tuna-cli 0.39, this has changed. The CLI on a laptop signs in via a device session, and for CI, servers, and services, API keys with specific permissions replace the token. The old token continues to work, but the CLI warns about the replacement.

In short
  • tuna login signs in via the browser and creates a device session. Sessions are visible in your profile; terminating a session immediately stops that device's tunnels.
  • Tuna Token has been migrated to API keys. The old token is already converted to a key with tunnel launch permissions and works as before.
  • In CI and Docker, replace TUNA_TOKEN with TUNA_API_KEY; reinstall services. Terraform and the Kubernetes operator already use keys.

Device session sign-in​

tuna login

The browser opens; after confirmation, the CLI saves the session in the system keychain: Keychain on macOS, Credential Manager on Windows, Secret Service on Linux. Tuna Desktop starting from version 0.3 also signs in via a device session.

On a server without a browser, sign in via a link: tuna login --no-browser shows a link and a code, and you can confirm from any device where you are already signed in. If you connected to the server via SSH, the CLI will suggest this method automatically.

Each device is a separate session. The list is available in your profile and via tuna session list. If a laptop is lost, terminate its session in the profile: that device's tunnels stop immediately while the rest keep running. There is no hard expiry for a session; it terminates after 30 days of inactivity, and a running tunnel extends it automatically.

API keys instead of Tuna Token​

For everything that runs unattended — CI, servers, Docker, a colleague with separate access — you now issue an API key. In the dashboard, open API keys → New key and select For tunnels:

New API key form: For tunnels option selected, tunnel launch enabled, with restrictions — HTTP tunnels, TCP and SSH tunnels, active and created tunnel limits

This key launches tunnels but does not access the API. You can restrict it to specific tunnel types — HTTP only, or TCP and SSH only — limit the number of simultaneously running tunnels, and set an expiration. The key is shown once, along with ready-made commands:

Created key dialog: warning to save the key now, hidden key tak_, and commands for CI with TUNA_API_KEY and for server with tuna login --with-api-key

New accounts no longer get a token on registration: the token page in the dashboard has been replaced by the API keys page.

What happens to the old token​

Nothing breaks. All tt_… tokens have been migrated to API keys with tunnel launch permissions: they start tunnels as before and, as before, do not access the API. Older CLI and Tuna Desktop versions also continue to work.

The new CLI accepts TUNA_TOKEN, the --token flag, and the token field in the config file, but logs a deprecation warning. There is no deadline for disabling old tokens. We will announce one in advance.

What to do​

  • Laptop. Run tuna login.
  • CI and Docker. Rename the TUNA_TOKEN variable to TUNA_API_KEY or pass the key with the --api-key flag. The same value works, but it is better to issue a separate key for each task so you can revoke it without affecting the others.
  • Background services. Sign in with tuna login and reinstall the service with tuna service install. Each service now gets its own key, tied to the tunnel type and address if specified, and tuna service uninstall revokes that key.
  • Terraform and Kubernetes operator. No action needed: the provider and operator have used API keys from the start.

A detailed guide for each scenario, including servers without a keychain and questions about tuna logout, is in the Migrating to sessions and API keys section.

Leave feedback​

If you enjoy using Tuna, or on the contrary you are not happy with something, please leave feedback.

News​

We announce new features and posts on our Telegram channel. Subscribe so you don't miss anything.

Help​

We value our users and carefully review every request. If you have any problems with tuna, please contact us in one of the following ways: