This describes how I set up TPM2 hardware-backed SSH keys using tpm2-pkcs11 on NixOS. Keys are generated inside the TPM and cannot be extracted, providing hardware-bound authentication.
- Uses the kernel resource manager (
/dev/tpmrm0) directly—notpm2-abrmddaemon needed - Uses the
esysdbbackend instead of FAPI for simpler configuration - Integrates with
passfor PIN storage (non-interactive operation) - Provides helper scripts for key management