CLI Commands
import { Aside } from ‘@astrojs/starlight/components’;
Kotauth includes a set of CLI subcommands accessible via java -jar kauth.jar cli <command>. These tools handle operations that should not require a running HTTP server or browser session — key generation, emergency account recovery, tenant backup/restore, etc.
java -jar kauth.jar cli <command> [options]When running with Docker Compose, use docker compose exec:
docker compose exec kauth java -jar kauth.jar cli <command> [options]Or with the Makefile shortcuts:
make generate-keymake reset-mfa USER=admingenerate-secret-key
Section titled “generate-secret-key”Generates a cryptographically secure 32-byte hex string suitable for KAUTH_SECRET_KEY.
java -jar kauth.jar cli generate-secret-keyOutput:
a1b2c3d4e5f6... # 64-character hex stringThis command is pure cryptography — it does not connect to the database or require any environment variables. Use it to provision a new key before first startup or when rotating an existing key.
reset-admin-mfa
Section titled “reset-admin-mfa”Resets MFA enrollment for a user on the master tenant. This is the recovery path when an admin loses access to their authenticator app and all recovery codes.
java -jar kauth.jar cli reset-admin-mfa --username=adminThis command connects to the database directly (using DB_* environment variables) without running Flyway migrations or starting the HTTP server. It removes the TOTP secret and recovery codes for the specified user, forcing re-enrollment on the next login.
| Option | Required | Description |
|---|---|---|
--username | Yes | The username of the admin account to reset |
export-tenant
Section titled “export-tenant”Exports a workspace as an encrypted archive file. The archive uses the bkp1 envelope format with PBKDF2 (600,000 iterations) key derivation and AES-256-GCM encryption.
java -jar kauth.jar cli export-tenant \ --slug=my-workspace \ --output=/backups/my-workspace.bkp1 \ --passphrase="your-strong-passphrase"| Option | Required | Description |
|---|---|---|
--slug | Yes | Workspace slug to export |
--output | Yes | Output file path |
--passphrase | Yes | Encryption passphrase |
The archive contains all tenant data: users, roles, groups, applications, sessions, audit logs, attributes, claim mappers, and settings.
import-tenant
Section titled “import-tenant”Imports a workspace from an encrypted archive file. Validates schema-version compatibility before applying any data.
java -jar kauth.jar cli import-tenant \ --input=/backups/my-workspace.bkp1 \ --passphrase="your-strong-passphrase"| Option | Required | Description |
|---|---|---|
--input | Yes | Archive file path |
--passphrase | Yes | Decryption passphrase |
See Backup & Restore for full documentation on the archive format, API endpoints, and schema compatibility.