Protecting SSH Keys with macOS Secure Enclave gatezh.com · 331 points · 120 comm...
HN Best 30 @best30
Protecting SSH Keys with macOS Secure Enclave gatezh.com · 331 points · 120 comments · HN thread
TL;DR The author describes how to store SSH keys in the macOS Secure Enclave using sc_auth and ssh-keygen with the CryptoTokenKit provider, with Touch ID required for every signature. He found the native route ugly (an unpolished Touch ID prompt and a fragile setup) and switched to the third-party app Secretive, which uses the same hardware with a better UI. The HN thread (120 comments) is mostly about alternatives like YubiKeys, 1Password, Secretive, and whether this hardware protection meaningfully improves security.
- Secure Enclave keys are created with sc_auth create-ctk-identity using -k p-256-ne (non-exportable P-256) and -t bio (Touch ID per use); the private key cannot be exported or backed up.
- Setup needs an export of a key handle via ssh-keygen -w /usr/lib/ssh-keychain.dylib -K, the SSH_SK_PROVIDER environment variable, and an explicit IdentityFile entry in ~/.ssh/config because SSH does not auto-discover the handle filename.
- Common pitfalls: a Touch ID enrollment reset caused error -25293, ssh-add -K is deprecated, and 1Password's SSH agent can conflict with the setup.
- The native Touch ID prompt reads 'ctccardtoken needs to authenticate', which the author found unacceptable, so he moved to Secretive.
- Losing the Mac means losing the key, so the author recommends keeping a second key (YubiKey or another Mac) in authorized_keys as a backup.
Discussion The thread is a mix of practical advice and skepticism. Many commenters already use Secretive, 1Password, or YubiKeys and share workflow tips, such as agent forwarding, PAM-based sudo, and CA-signed keys. A large side discussion concerns WireGuard's macOS app, which lost profiles after an OS upgrade via a keychain error, used as an example of how fragile Apple's security APIs can be. Overall the tone is pragmatic and somewhat wry, with several people arguing about what threat the hardware key actually defends against.
- Hardware-bound keys are worth it despite the friction (many): Several users say non-exportable keys tied to Touch ID or a YubiKey meaningfully limit damage from malware and stolen files, and they accept the extra taps. Secretive is repeatedly recommended as the easier front end.
- Secretive or 1Password is the practical choice (many): Commenters prefer Secretive for macOS Secure Enclave keys and 1Password's agent for shareable keys, citing better UI and per-key settings. Some note that 1Password agent prompts can be triggered by AI agents and cause fatigue.
- Secure Enclave and TPM APIs are poorly documented and fragile (some): People point to the WireGuard keychain incident, undocumented Apple APIs, and setup pitfalls as reasons these features can lock users out or break after updates.
- Threat model is weak; passphrases or sandboxing matter more (some): Some argue a malicious script with filesystem access can still hijack ssh, so the hardware key mainly adds presence checks. Others say passphrase-protected keys with ssh-agent already cover much of this.
- Hardware keys need to stay on the user's side for AI agents (a few): A few commenters value that the key requires physical presence, so AI agents running headless cannot use production keys without the user noticing.
Links from the comments