hevd key file migration
Move hevd’s Layer key to a protected file
This procedure applies to primary Layer capture in 0.7+.
hevd reads the primary archive key at startup before starting its secrets
sidecar. A daemon that previously relied on a primary key reference needs
a protected file or a compatible literal credential. If you keep a legacy
inline [layer].api_key, protect the config as described below and restart.
An existing literal HEVLAYER_API_KEY in the daemon environment is also
compatible when the file setting is absent.
-
Find the config used by the daemon. Check the service’s
HEV_CONFIGoverride, if any. Keep a protected copy of the prior config and the compatible binary for rollback. -
Provision a regular local file containing the narrow key for the current archive on a single line. Use the daemon account and the platform protections below for both files. Keep the value out of command arguments, shell history, logs and support messages.
-
Add
api_key_fileto the existing[layer]table. Relative paths resolve from the config directory. Keep the effective endpoint and namespace, including any service overrides. For example, with synthetic values:[layer] endpoint = "https://layer.example.test" namespace = "example-traces" api_key_file = "credentials/layer.key"Remove the superseded inline key and daemon-only reference for the primary archive. Preserve any independent CLI references or scoped credential settings, including those used by secondary capture targets. The file setting takes precedence over both legacy literal sources, even if the configured file is unusable.
-
Restart hevd through its existing service manager, or stop and relaunch
hev dunder the same account with the same config. Runhev statuson that host and check that capture is running, reports Layer and has a recent successful scan. Create a new synthetic session, wait for capture and confirm it appears in the intended Layer endpoint and namespace using an independently authenticated reader. If a scan fails, check the redacted errors. A credential error on the primary target does not switch it to files or another key. Eligible secondary targets still use their own credentials.
Protect both files
- Unix. Use regular files owned and readable by the effective daemon
user.
0600and0400are both suitable. The reader rejects group or other permission bits and symlinks. Every directory component below the root must be owned by root or the daemon user. Group- or other-writable directories are refused unless sticky. Use a private daemon-owned directory such as mode0700. - Windows. Use regular files on a fixed local drive. hevd checks each file and its immediate parent directory for reparse points and private DACLs. On each checked object, disable ACL inheritance, remove inherited entries and any explicit entries for other principals. Use only explicit allow entries for the daemon account, SYSTEM or Administrators, with an owner from that same set. Give the daemon account read access to the file and its parent. The reader checks the immediate parent rather than every ancestor, so choose a trusted location for the full path.
Repair the Windows ACL
Run this in PowerShell 7 as the daemon account. Use a dedicated directory
on a fixed local drive containing both files. Confirm that all three
objects already have an allowed owner and that the directory and regular
files are free of reparse points. The procedure replaces the DACL on each
listed object and preserves ownership. Set $paths to the dedicated
directory, config and key file. Substitute your own paths for these
placeholders.
$paths = @(
'C:\example\hevd-private'
'C:\example\hevd-private\config.toml'
'C:\example\hevd-private\layer.key'
)
$ErrorActionPreference = 'Stop'
$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
$sddl = "D:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;${sid})"
foreach ($path in $paths) {
$item = Get-Item -LiteralPath $path
if ($item.PSIsContainer) {
$acl = [System.Security.AccessControl.DirectorySecurity]::new()
} else {
$acl = [System.Security.AccessControl.FileSecurity]::new()
}
$acl.SetSecurityDescriptorSddlForm($sddl, [System.Security.AccessControl.AccessControlSections]::Access)
[System.IO.FileSystemAclExtensions]::SetAccessControl($item, $acl)
}
Restart hevd and verify a fresh capture in the intended Layer archive.
Restart or intentionally change a managed target
hev up refuses a config with api_key_file, including with an explicit
--store. hev init can ask whether to update an existing config, then
refuses before prompting for target values or writing changes. The
invite commands also refuse the
managed target. An empty file setting still triggers these guards.
For an intentional change that keeps disk bootstrap, stop the writer,
prepare the new protected config and credential, then restart hevd directly
and verify capture. To hand the target back to a setup or invite command,
stop hevd, keep a protected rollback copy, explicitly remove
api_key_file from the active config and review the intended endpoint,
namespace and credential before running the command. Keep the key file
protected while retained for rollback. Only run hev leave if you intend
to revoke the invitation’s keys and delete its archive.
Rotate or roll back
Stage a complete replacement in the same directory with the correct ownership and permissions or DACL. Atomically replace the old file on the same filesystem. Restart hevd to load it, then verify a fresh capture before revoking the retired key. The gateway enforces revocation on subsequent requests. Restoring a revoked key still results in refusal.
To undo a rotation, atomically restore a protected file with a still-valid
key, restart and verify capture. To downgrade to a binary that predates
api_key_file, stop capture and restore the prior compatible binary and
its protected config together, including any required legacy service
credential source. Restart and verify the intended archive before
resuming normal capture.