Skip to content

init

Initialize new kiln projects with encryption keys and configuration files.

Terminal window
kiln init key [options]
kiln init config [options]

The init command provides two subcommands for setting up kiln projects:

  • key - Generate age encryption key pairs
  • config - Create configuration files with recipients and access control

Generate a new age encryption key pair for secure environment variable management.

Terminal window
kiln init key [--path <path>] [--encrypt] [--force]
  • --path <path>: Key file location (default: ~/.kiln/kiln.key)
  • --encrypt: Protect private key with passphrase
  • --force: Overwrite existing key files

Generate a new key pair:

Terminal window
kiln init key

Generate with custom path:

Terminal window
kiln init key --path ./keys/production.key

Generate with passphrase protection:

Terminal window
kiln init key --encrypt

The command creates two files:

  • Private key: <path> (mode 0600)
  • Public key: <path>.pub (mode 0600)

The public key is displayed and should be shared with team members who need to add you as a recipient.

Create a new kiln configuration file with recipients and file definitions.

Terminal window
kiln init config [--path <path>] [--recipients name=key] [--force]
  • --path <path>: Configuration file location (default: kiln.toml)
  • --recipients name=key: Named recipients in name=public-key format
  • --force: Overwrite existing configuration

Create configuration with recipients:

Terminal window
kiln init config --recipients "alice=age1234...abcd" --recipients "bob=ssh-ed25519 AAAAC3..."

Create with custom path:

Terminal window
kiln init config --path ./deploy/kiln.toml

Recipients can be specified in two formats:

Age public keys:

Terminal window
--recipients "alice=age1234567890abcdef..."

SSH public keys:

Terminal window
--recipients "bob=ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGb..."

From file:

Terminal window
--recipients "charlie=~/.ssh/id_ed25519.pub"

The command creates a kiln.toml file with:

[recipients]
alice = "age1234567890abcdef..."
bob = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGb..."
[files]
[files.default]
filename = ".kiln.env"
access = ["*"]

Configuration files contain only public keys and can be safely committed to version control.

Terminal window
# Generate personal key
kiln init key
# Create configuration with your public key
kiln init config --recipients "$(whoami)=$(cat ~/.kiln/kiln.key.pub)"
Terminal window
# Team lead generates shared configuration
kiln init config \
--recipients "alice=age1234...abcd" \
--recipients "bob=ssh-ed25519 AAAAC3..." \
--recipients "charlie=~/.ssh/id_ed25519.pub"
Terminal window
# Generate production key with passphrase
kiln init key --path ./keys/prod.key --encrypt
# Create restricted configuration
kiln init config --path ./prod-kiln.toml \
--recipients "admin=$(cat ./keys/prod.key.pub)"

The init command validates all inputs and provides clear error messages:

  • Key exists: Use --force to overwrite existing keys
  • Invalid path: Path must be accessible and writable
  • Invalid public key: Public key format must be valid age or SSH key
  • Permission denied: Directory must be writable
Terminal window
# Generate ephemeral keys for CI
kiln init key --path /tmp/ci.key
# Use existing keys in configuration
kiln init config --recipients "ci=$(cat /tmp/ci.key.pub)"
Terminal window
# New team member shares their public key
kiln init config --recipients "newmember=age1new...member"
# Or use their SSH key
kiln init config --recipients "newmember=$(curl -s https://github.com/username.keys)"
  1. Use descriptive recipient names that match team member identities
  2. Store private keys securely with appropriate file permissions
  3. Use passphrase encryption for production and shared environments
  4. Version control configuration files but never private keys
  5. Document key locations and backup procedures for your team