Host setup
Run each Knock Door on a dedicated Ubuntu 24.04 LTS x86-64 host (2 GiB RAM, cgroup v2, kernel WireGuard, nftables, time sync enabled, suspend disabled) with operator management SSH on a separate interface.
Reserved host resources
Section titled “Reserved host resources”knockd owns a small isolated network slice and firewall table so Knock teardown never interferes with unrelated system rules:
- WireGuard interface:
knockdoor - nftables table:
inet knock_ssh - Protected subnet:
198.19.0.0/28(Door address198.19.0.1) - Per-session OpenSSH listeners: TCP ports
2222to2229bound to198.19.0.1 - Runtime tmpfs state:
/run/knock-ssh
Allow inbound UDP on the configured wireGuardEndpoint port through your external interface firewall, and block public access to ports 2222 to 2229.
Create non-root SSH slot accounts
Section titled “Create non-root SSH slot accounts”For an Approval Door, install OpenSSH and create pre-provisioned non-root slot accounts with password login disabled (NP leaves the account locked for password auth while allowing certificate auth):
sudo useradd --system --no-create-home --home-dir / --shell /bin/sh --password NP knocksshsudo useradd --system --no-create-home --home-dir / --shell /bin/sh --password NP knockssh1sudo install -d -m 0755 /run/sshdInstall knockd and systemd units
Section titled “Install knockd and systemd units”Run these commands from the extracted Linux release archive or a source checkout built with make build.
Keep /etc/knock (0700) and the Door profile (0600) root-owned, and keep the ownerProfile off the Door host entirely.
Encrypt the Door passphrase with systemd host-bound credentials and install the shipped unit and drop-in (deploy/systemd/knockd.service and deploy/systemd/10-ssh.conf):
sudo install -m 0755 bin/knockd /usr/local/bin/knockdsudo install -d -m 0700 /etc/knocksudo install -d -m 0755 /etc/systemd/system/knockd.service.dsystemd-ask-password 'Door passphrase' | sudo systemd-creds encrypt --name=door-passphrase --with-key=host - /etc/knock/door.credsudo install -m 0644 deploy/systemd/knockd.service /etc/systemd/system/knockd.servicesudo install -m 0644 deploy/systemd/10-ssh.conf /etc/systemd/system/knockd.service.d/10-ssh.confsudo systemctl daemon-reloadsudo systemctl start knockdThe 10-ssh.conf drop-in runs knockd as root because managing knockdoor, inet knock_ssh, /run/knock-ssh, and transient systemd-run session slices requires kernel and systemd privilege.
Requester Linux setup
Section titled “Requester Linux setup”On the requester Linux machine, install bin/knock to /usr/local/bin/knock, install wireguard-tools and OpenSSH, and add the scoped sudoers rule from deploy/knock-tunnel.sudoers (replacing knockclient with your requester group):
sudo visudo -f /etc/sudoers.d/knock-tunnel%knockclient ALL=(root) NOPASSWD: /usr/local/bin/knock ^tunnel-(up|down)\ kc[0-9a-f]{12}$This permits knock to bring up and tear down its temporary kc... WireGuard interface without granting general root privileges.
Manual host reconciliation
Section titled “Manual host reconciliation”If a Door host stops abruptly or requires manual verification before restarting knockd, inspect and clean up any leftover Knock peers, permits, or session units:
sudo knockd reconcile --config /etc/knock/door.json