Skip to content

Configuration

Kod can be configured through CLI flags, environment variables, or a combination of both. CLI flags take the highest priority.

  1. CLI flags (highest priority)
  2. Environment variables
  3. Config file (~/.kod/server.json)
  4. Default values (lowest priority)
VariableDescriptionDefault
KOD_PORTPort to listen on3000
KOD_DATA_DIRDirectory for database files~/.kod/data
KOD_REPOS_DIRDirectory for Git repositories~/.kod/repos
KOD_API_TOKENAPI token for authentication-
KOD_ADMIN_TOKENAdmin token for first-time bootstrap-
KOD_ENCRYPTION_KEYEncryption key for secrets-
Terminal window
kod serve [options]
Options:
--port, -p <port> Port to listen on (default: 3000)
--data-dir <path> Data directory for database
--repos-dir <path> Directory for Git repositories
--token <token> API token for authentication
--admin-token <token> Admin token for first-time setup
--encryption-key <key> Encryption key for secrets
Terminal window
# Minimal: start with admin token
KOD_ADMIN_TOKEN=kod_my_secret kod serve
# Custom port and directories
kod serve --port 8080 --data-dir /var/kod/data --repos-dir /var/kod/repos
# All via environment variables
KOD_PORT=8080 \
KOD_ADMIN_TOKEN=kod_my_secret \
KOD_ENCRYPTION_KEY=my-encryption-key \
kod serve

The admin token bootstraps authentication on first server start. Without it, the server has no authentication and will log a warning.

There are two ways to provide it:

Terminal window
# Environment variable
KOD_ADMIN_TOKEN=kod_my_secret kod serve
# CLI flag
kod serve --admin-token kod_my_secret

After the server starts, use this token for all API and CLI operations. You can then create additional tokens with specific permissions:

Terminal window
kod token create ci-deploy --permissions repo:read,workflow:trigger

The encryption key is required for the Secrets feature. It encrypts secret values at rest using AES-256-GCM.

Terminal window
# Generate a key
openssl rand -base64 32
# Provide it to the server
KOD_ENCRYPTION_KEY=your-generated-key kod serve
# Or via CLI flag
kod serve --encryption-key your-generated-key

The CLI client stores its configuration in ~/.kod/config.json:

{
"serverUrl": "http://localhost:3000",
"apiToken": "kod_your_token"
}

Set it up interactively:

Terminal window
kod init

When installed globally (npm install -g kod), Kod includes a Git credential helper (git-credential-kod). Running kod init automatically configures Git to use it for the server host, so plain git clone, git push, and git pull authenticate without prompting.

To configure it manually:

Terminal window
git config --global credential.http://localhost:3000.helper kod

Or override per-command:

Terminal window
# Via flags
kod -t kod_my_token -s http://myserver:3000 repo list
# Via environment variables
KOD_API_TOKEN=kod_my_token KOD_SERVER_URL=http://myserver:3000 kod repo list
VariableDescriptionDefault
KOD_API_TOKENAPI token for authentication-
KOD_SERVER_URLServer URL for client commandshttp://localhost:3000

For production, we recommend:

  1. Use a reverse proxy (Caddy or nginx) for automatic HTTPS
  2. Set a strong admin token and generate scoped tokens for users and CI
  3. Set an encryption key if you use secrets
  4. Run as a systemd service for automatic restarts
/etc/systemd/system/kod.service
[Unit]
Description=Kod Git Server
After=network.target
[Service]
Type=simple
User=kod
Environment="KOD_ADMIN_TOKEN=kod_your_secret"
Environment="KOD_ENCRYPTION_KEY=your-encryption-key"
Environment="KOD_DATA_DIR=/var/kod/data"
Environment="KOD_REPOS_DIR=/var/kod/repos"
ExecStart=/usr/local/bin/kod serve
Restart=always
[Install]
WantedBy=multi-user.target
/etc/caddy/Caddyfile
git.example.com {
reverse_proxy localhost:3000
}