UpCloud
Installs upctl (the UpCloud CLI) and configures shell aliases and per-shell account selection.
What it does
- Auto-installs and updates upctl to the latest GitHub release (checksum-verified release tarball on Linux, the
UpCloudLtd/tapHomebrew tap on macOS) - Registers
upctlin~/.versions.d/soversionsreports its version - Keeps UpCloud account selection per-shell (
UPCLOUD_TOKEN) so terminals never collide, see Per-shell isolation - Flags a missing or rejected token when you switch accounts with
upctl-account, pointing you atupctl-authenticate - Installs bash completion generated by
upctl completion bash, plus tab completion for the account functions
Variables
| Variable | Default | Description |
|---|---|---|
upcloud_upctl_version | latest | Pin upctl to an exact version, or track the newest release |
upcloud_aliases | See defaults | Shell aliases to generate |
upcloud_functions | See defaults | Shell functions to generate |
upcloud_completions | See defaults | Completion wiring for the functions |
upcloud_upctl_version: "3.37.0" # latestAliases
| Alias | Command | Description |
|---|---|---|
upcloud | upctl-account | Show / switch the UpCloud account |
upctl-servers | upctl server list | List servers in the current account |
Functions
| Function | Description |
|---|---|
upctl-authenticate | Prompt for an API token and store it as a named account |
upctl-account | Show the current account, or switch to a named one (warns on a missing or rejected token); --short prints its line in accounts |
Authentication
The role installs the binary but leaves you signed out, so nothing writes credentials during an apply. Create an API token in the UpCloud Hub, then store it under a name of your choice:
upctl-authenticate companyThe function prompts for the token without echoing it, writes ~/.config/upctl/accounts/company.yaml with mode 0600, and switches the shell to that account. The file uses upctl's own config format (token: "..."), so upctl --config ~/.config/upctl/accounts/company.yaml reads it too.
An UpCloud sub-account is a separate user with its own credentials. Sign in to the Hub as the sub-account, create its token there, and store it under its own name (upctl-authenticate company-billing).
Per-shell isolation
upctl reads its credentials from one shared ~/.config/upctl.yaml or from one system keyring entry, which upctl account login --with-token writes. Neither holds more than one token, and upctl reads no environment variable that points it at another config file. It does read UPCLOUD_TOKEN, which overrides both. upctl-account <name> exports UPCLOUD_TOKEN from the account's file, so picking an account in one terminal can't change which UpCloud account another terminal acts on, and that includes a coding agent like Claude Code running its own shell. The UpCloud Terraform provider reads UPCLOUD_TOKEN as well, so terraform plan in that shell uses the same account.
upctl-account also exports UPCTL_ACCOUNT with the account name, which accounts and the starship prompt read (🆙 <account>), so each shell visibly shows the account it is on. Run upctl-account with no argument to show the current account and its API username, and to list the accounts you have. This is the per-shell context isolation concept applied to UpCloud.
Troubleshooting
A shell acts on an account you didn't select
A shell without a selected account has no UPCLOUD_TOKEN, so upctl falls back to the token in ~/.config/upctl.yaml, the UPCLOUD_USERNAME and UPCLOUD_PASSWORD variables, or the keyring token. Run upctl-account <name> in that shell, or remove the shared token from ~/.config/upctl.yaml and the keyring so an unselected shell has no credentials at all.
invalid user credentials
upctl exits with code 103 and Error: invalid user credentials when the API rejects the token, for example after it was deleted or expired in the Hub. upctl-account <name> prints the same finding as a warning. Create a new token and run upctl-authenticate <name> again.