Environment Variables Reference
This document provides a comprehensive reference for all environment variables used in the KrakenHashes system.
Table of Contents
Backend Server
Core Configuration
| Variable | Type | Default | Required | Description |
KH_HOST | string | localhost (or 0.0.0.0 in Docker) | No | Host address for the server to bind to |
KH_HTTPS_PORT | integer | 31337 | No | Port for HTTPS API server |
KH_HTTP_PORT | integer | 1337 | No | Port for HTTP server (CA certificate distribution) |
KH_IN_DOCKER | boolean | false | No | Set to TRUE when running in Docker container |
Data & Storage
| Variable | Type | Default | Required | Description |
KH_CONFIG_DIR | string | ~/.krakenhashes | No | Base directory for configuration files |
KH_DATA_DIR | string | ~/.krakenhashes-data | No | Base directory for mutable data (uploads, binaries, etc.) |
KH_HASHLIST_BATCH_SIZE | integer | 1000 | No | Maximum number of hashes to process in one database batch |
KH_MAX_UPLOAD_SIZE_MB | integer | 32 | No | Maximum file upload size in megabytes |
KH_HASH_UPLOAD_DIR | string | {KH_DATA_DIR}/hashlist_uploads | No | Directory for storing uploaded hashlists |
Network Share Storage
Optional. Lets the server keep its wordlists and rules on a mounted network share instead of local disk, so servers (and select agents) don't each need a large SSD. See Storage Architecture for the full model.
| Variable | Type | Default | Required | Description |
KH_SHARE_DIR | string | - | No | In-container path where the network share is mounted (set via docker-compose). When the storage backend is switched to share, the server serves wordlists/ and rules/ from here. Leave unset for local-only storage |
KH_MIGRATION_DRAIN_FLOOR_SECONDS | integer | 720 | No | Minimum drain window (seconds) before a local↔share migration locks writes, sized to the agent reconnect back-off. Lower it only in dev (e.g. 10) |
Whether the server reads wordlists/rules from local disk or the share is database state (storage_backend = local|share), flipped by the in-app migration — not an environment variable. Hashlists, binaries, charsets, uploads and the potfile always stay local. The share is mounted by docker-compose with the operator's own credentials; KrakenHashes stores no share credentials.
Directory Structure
The backend automatically creates the following subdirectories under KH_DATA_DIR: - binaries/ - Executable files (hashcat, john, etc.) - wordlists/ - Wordlist files with subdirectories: - general/ - Common wordlists - specialized/ - Domain-specific wordlists - targeted/ - Client/project-specific wordlists - custom/ - User-created wordlists - rules/ - Rule files with subdirectories: - hashcat/ - Hashcat-compatible rules - john/ - John the Ripper rules - custom/ - User-created rules - hashlists/ - Hash files and crack results
Frontend Application
API Configuration
| Variable | Type | Default | Required | Description |
REACT_APP_API_URL | string | https://localhost:31337 | Yes | HTTPS API endpoint URL |
REACT_APP_HTTP_API_URL | string | http://localhost:1337 | No | HTTP API endpoint URL (for CA cert download) |
REACT_APP_WS_URL | string | wss://localhost:31337 | Yes | WebSocket endpoint URL |
REACT_APP_VERSION | string | (from versions.json) | No | Frontend version (set during build) |
Development Server
| Variable | Type | Default | Required | Description |
HTTPS | boolean | true | No | Enable HTTPS for development server |
SSL_CRT_FILE | string | - | No | Path to SSL certificate for dev server |
SSL_KEY_FILE | string | - | No | Path to SSL key for dev server |
HOST | string | 0.0.0.0 | No | Development server host |
PORT | integer | 3000 | No | Development server port |
NODE_ENV | string | development | No | Node environment |
BROWSER | string | none | No | Browser launch behavior |
Debug Configuration
| Variable | Type | Default | Required | Description |
REACT_APP_DEBUG | boolean | false | No | Enable debug mode in React app |
REACT_APP_DEBUG_REDUX | boolean | false | No | Enable Redux debugging |
Agent
Core Configuration
| Variable | Type | Default | Required | Description |
KH_DATA_DIR | string | {executable_dir}/data | No | Base directory for agent data |
KH_CONFIG_DIR | string | {executable_dir}/config | No | Directory for agent configuration files |
HASHCAT_EXTRA_PARAMS | string | - | No | Extra parameters to pass to hashcat (e.g., -O -w 3) |
The agent creates the same directory structure as the backend under its data directory.
Storage Tier
Controls how an agent obtains wordlists/rules. These are a seed: they set the agent's initial tier/mount, reported to the server at registration; afterwards the admin UI (Admin → System Settings → Storage, per agent) is authoritative and re-asserts its value on each reconnect. Equivalent CLI flags are --storage-tier and --network-share-mount-path. See agent configuration.
| Variable | Type | Default | Required | Description |
KH_STORAGE_TIER | string | full_cache | No | full_cache (download & keep all lists), on_demand (download per task, evict under disk pressure), or network_direct (read lists off a mounted share; on-prem only). An unknown value, or network_direct with no mount path, falls back to full_cache |
KH_NETWORK_SHARE_MOUNT_PATH | string | - | No | Read-only mount path the network_direct tier reads from (e.g. /mnt/kh-agent-share). You must mount the share here yourself before starting the agent; the agent never mounts anything |
KH_AGENT_ONDEMAND_TARGET_FREE_GB | integer | 20 | No | on_demand tier only: free-space target (GiB) below which least-recently-used wordlist/rule files are evicted. Files in use by a running task are never evicted |
Docker & Deployment
Container Configuration
| Variable | Type | Default | Required | Description |
PUID | integer | 1000 | No | User ID for file permissions |
PGID | integer | 1000 | No | Group ID for file permissions |
TZ | string | UTC | No | Container timezone |
Volume Mounts
| Variable | Type | Default | Required | Description |
LOG_DIR | string | /var/log/krakenhashes | No | Base directory for log files |
KH_CONFIG_DIR_HOST | string | /etc/krakenhashes | No | Host path for config directory |
KH_DATA_DIR_HOST | string | /var/lib/krakenhashes | No | Host path for data directory |
KH_SHARE_DIR_HOST | string | - | No | Host path (or mounted network-share path) bind-mounted into the backend at KH_SHARE_DIR. Set this only when using network share storage |
Port Mappings
| Variable | Type | Default | Required | Description |
FRONTEND_PORT | integer | 443 | No | Host port for frontend (nginx) |
Database
Connection Settings
| Variable | Type | Default | Required | Description |
DB_HOST | string | localhost | Yes | Database host |
DB_PORT | integer | 5432 | Yes | Database port |
DB_NAME | string | krakenhashes | Yes | Database name |
DB_USER | string | krakenhashes | Yes | Database username |
DB_PASSWORD | string | krakenhashes | Yes | Database password |
DB_ARGUMENTS | string | sslmode=disable | No | Additional connection arguments (e.g., sslmode=require&connect_timeout=5) |
The backend builds the connection string dynamically from these variables.
Authentication & Security
JWT Configuration
| Variable | Type | Default | Required | Description |
JWT_SECRET | string | - | Yes | Secret key for JWT token signing |
JWT_EXPIRATION | string | 24h | No | JWT token expiration time |
DEFAULT_ADMIN_ID | string | - | No | User ID of the default admin |
CORS Configuration
| Variable | Type | Default | Required | Description |
CORS_ALLOWED_ORIGIN | string | https://localhost:443 | No | Allowed CORS origin |
ALLOWED_ORIGINS | string | * | No | Comma-separated list of allowed origins |
Secret Encryption
| Variable | Type | Default | Required | Description |
KH_ENCRYPTION_KEY | string | - | No | AES-256-GCM key for every secret stored in the database (SSO secrets, cloud provider credentials, VPN enrollment credentials). Generate with openssl rand -base64 32. If unset, the server generates and persists one — see below |
SSO_ENCRYPTION_KEY | string | - | No | Legacy, SSO-scoped name for the same key. Still fully honored. Used only when KH_ENCRYPTION_KEY is unset |
KH_ALLOW_EPHEMERAL_KEY | bool | false | No | Boot with a throwaway key when none can be persisted, instead of refusing to start. Development only |
The key is resolved in this order:
KH_ENCRYPTION_KEY SSO_ENCRYPTION_KEY (legacy) $KH_CONFIG_DIR/secrets/encryption.key — generated on first boot at mode 0600 inside a 0700 directory, then reused on every later start - A throwaway key, only when
KH_ALLOW_EPHEMERAL_KEY=true
Setting either variable is therefore optional: a server with neither still keeps its secrets across restarts. Set one explicitly to hold the key outside the config directory, or to share a single key across several servers.
Back up the generated key file
$KH_CONFIG_DIR/secrets/encryption.key is the only copy. Without it, stored cloud provider credentials, VPN enrollment credentials and SSO secrets cannot be decrypted and must be re-entered.
The server refuses to start on a key it cannot use
If the key file exists but is unreadable, empty, or the wrong length, startup fails and names the path. It is never silently replaced — regenerating would turn one bad file into every stored secret becoming permanently undecryptable, which would not surface until a cloud launch or an SSO login failed much later. Restore it from backup, or delete it deliberately to start over with new secrets.
Do not set both to different values
If KH_ENCRYPTION_KEY and SSO_ENCRYPTION_KEY are both set to different values, KH_ENCRYPTION_KEY wins and anything previously encrypted under the legacy key (SSO bind passwords, SAML private keys, OAuth client secrets) will fail to decrypt until re-entered. To migrate, copy the existing SSO_ENCRYPTION_KEY value into KH_ENCRYPTION_KEY and remove the old variable.
SSO Configuration
| Variable | Type | Default | Required | Description |
KH_EXTERNAL_URL | string | - | No | External URL for SSO redirect callbacks (e.g., https://krakenhashes.local:8443). Required when behind a reverse proxy on a nonstandard port. Falls back to request Host header if unset |
Single-Instance Guard
Only one backend may run against a given database: the job scheduler's concurrency guard is process-local, so two backends dispatch the same keyspace intervals twice.
| Variable | Type | Default | Required | Description |
KH_INSTANCE_LOCK_WAIT | int | 30 | No | Seconds to wait for an outgoing process to release the lock before giving up. Covers rolling restarts |
KH_ALLOW_MULTIPLE_INSTANCES | bool | false | No | Disable the guard entirely. Doing so double-dispatches job chunks and, with cloud provisioning enabled, can launch duplicate paid GPU instances |
TLS/SSL Configuration
Certificate Mode
| Variable | Type | Default | Required | Description |
KH_TLS_MODE | string | self-signed | No | TLS mode: self-signed, provided, or certbot |
KH_CERTS_DIR | string | {KH_CONFIG_DIR}/certs | No | Directory for storing certificates |
Certificate Details
| Variable | Type | Default | Required | Description |
KH_ADDITIONAL_DNS_NAMES | string | - | Recommended | Comma-separated additional DNS names for certificates |
KH_ADDITIONAL_IP_ADDRESSES | string | - | Recommended | Comma-separated additional IP addresses for certificates |
Self-Signed CA Configuration
| Variable | Type | Default | Required | Description |
KH_CA_COUNTRY | string | US | No | CA certificate country code |
KH_CA_ORGANIZATION | string | KrakenHashes | No | CA organization name |
KH_CA_ORGANIZATIONAL_UNIT | string | KrakenHashes CA | No | CA organizational unit |
KH_CA_COMMON_NAME | string | KrakenHashes Root CA | No | CA common name |
User-Provided Certificates
| Variable | Type | Default | Required | Description |
KH_CERT_FILE | string | {KH_CERTS_DIR}/server.crt | Yes* | Path to certificate file |
KH_KEY_FILE | string | {KH_CERTS_DIR}/server.key | Yes* | Path to private key file |
KH_CA_FILE | string | {KH_CERTS_DIR}/ca.crt | No | Path to CA certificate file |
* Required when KH_TLS_MODE=provided
Let's Encrypt (Certbot) Configuration
| Variable | Type | Default | Required | Description |
KH_CERTBOT_DOMAIN | string | - | Yes* | Domain name for Let's Encrypt |
KH_CERTBOT_EMAIL | string | - | Yes* | Email for Let's Encrypt notifications |
KH_CERTBOT_STAGING | boolean | false | No | Use Let's Encrypt staging server |
KH_CERTBOT_AUTO_RENEW | boolean | true | No | Enable automatic renewal |
KH_CERTBOT_RENEW_HOOK | string | - | No | Custom hook script after renewal |
CLOUDFLARE_API_TOKEN | string | - | Yes** | Cloudflare API token for DNS-01 challenge |
* Required when KH_TLS_MODE=certbot ** Required for DNS-01 challenge with Cloudflare
Logging & Debugging
Debug Flags
| Variable | Type | Default | Required | Description |
DEBUG | boolean | false | No | Enable global debug output |
LOG_LEVEL | string | INFO | No | Log level: DEBUG, INFO, WARNING, ERROR |
DEBUG_SQL | boolean | false | No | Enable SQL query logging |
DEBUG_HTTP | boolean | false | No | Enable HTTP request/response logging |
DEBUG_WEBSOCKET | boolean | false | No | Enable WebSocket message logging |
DEBUG_AUTH | boolean | false | No | Enable authentication debugging |
DEBUG_JOBS | boolean | false | No | Enable job processing debugging |
Log Directories
| Variable | Type | Default | Required | Description |
BACKEND_LOG_DIR | string | ${LOG_DIR}/backend | No | Backend log directory |
FRONTEND_LOG_DIR | string | ${LOG_DIR}/frontend | No | Frontend log directory |
NGINX_LOG_DIR | string | ${LOG_DIR}/nginx | No | Nginx log directory |
POSTGRES_LOG_DIR | string | ${LOG_DIR}/postgres | No | PostgreSQL log directory |
Nginx Logging
| Variable | Type | Default | Required | Description |
NGINX_ACCESS_LOG_LEVEL | string | info | No | Nginx access log level |
NGINX_ERROR_LOG_LEVEL | string | warn | No | Nginx error log level |
NGINX_CLIENT_MAX_BODY_SIZE | string | 50M | No | Maximum client body size |
WebSocket Configuration
| Variable | Type | Default | Required | Description |
KH_WRITE_WAIT | duration | 10s | No | Time allowed to write messages |
KH_PONG_WAIT | duration | 60s | No | Time to wait for pong response |
KH_PING_PERIOD | duration | 54s | No | How often to send pings |
Duration format: 10s, 5m, 1h, etc.
Environment Variable Priority
- Explicit environment variables take precedence
- Docker environment files (
.env) are loaded next - Default values are used as fallback
Best Practices
- Security: Never commit sensitive values (passwords, JWT secrets) to version control
- Production: Always set strong values for
JWT_SECRET, DB_PASSWORD, and certificate configurations - Development: Use
.env files for local development configuration - Docker: Mount configuration directories to persist data between container restarts
- Paths: Use absolute paths for file and directory configurations
- Validation: The backend validates critical environment variables on startup
Example Configurations
Minimal Development Setup
# .env
DB_HOST=localhost
DB_PORT=5432
DB_NAME=krakenhashes
DB_USER=krakenhashes
DB_PASSWORD=krakenhashes
DB_ARGUMENTS=sslmode=disable
JWT_SECRET=dev-secret-change-in-production
DEBUG=true
Production Docker Setup
# .env.production
PUID=1000
PGID=1000
DB_HOST=postgres
DB_PASSWORD=strong-random-password
JWT_SECRET=very-long-random-secret
KH_TLS_MODE=certbot
KH_CERTBOT_DOMAIN=kraken.example.com
KH_CERTBOT_EMAIL=admin@example.com
CLOUDFLARE_API_TOKEN=your-cloudflare-api-token
DEBUG=false
LOG_LEVEL=WARNING
Agent Configuration
# Agent environment
KH_DATA_DIR=/opt/krakenhashes-agent/data
KH_CONFIG_DIR=/opt/krakenhashes-agent/config
HASHCAT_EXTRA_PARAMS=-O -w 3