Protecting SSH Keys with macOS Secure Enclave gatezh.com · 72 points · 22 commen...
HN Best 200 @best
Protecting SSH Keys with macOS Secure Enclave gatezh.com · 72 points · 22 comments · HN thread
TL;DR The author walks through creating an SSH key inside the macOS Secure Enclave using built-in tools (sc_auth and ssh-keygen with the ssh-keychain.dylib provider), so the private key is non-exportable and each login requires Touch ID. The setup works, but the author rejects it for daily use because the Touch ID prompt reads 'ctccardtoken needs to authenticate' and the key cannot be backed up, so they plan to switch to Secretive.
- Keys are created with sc_auth create-ctk-identity using p-256-ne (non-exportable) and -t bio, which requires Touch ID for every signing operation.
- The Mac stores only a key handle on disk; the private key never leaves the Secure Enclave, so it cannot be copied even if the Mac is compromised.
- Older guides using ssh-add -K are deprecated and do not work with Secure Enclave keys; SSH_SK_PROVIDER=/usr/lib/ssh-keychain.dylib is the working approach.
- SSH does not auto-discover the handle file id_ecdsa_sk_rk, so it must be listed explicitly in ~/.ssh/config, and a 1Password SSH agent may conflict.
- Secure Enclave keys are bound to one Mac and cannot be backed up, so the author recommends registering a second key (YubiKey or another Mac) on servers.
- The Touch ID dialog is unpolished, which is the author's main reason for choosing Secretive instead.
Discussion The thread mostly shares experiences with hardware-backed and keychain-based key storage rather than debating the article's method directly. The most upvoted comment describes WireGuard's macOS keychain integration breaking after an OS upgrade and deleting profiles, which spawned a side discussion about keychain fragility and how hard it is to report bugs to WireGuard. Other commenters point to Secretive as a more usable wrapper, to YubiKeys, and to 1Password and gopass as alternatives. The mood is practical and mildly skeptical, with several people noting that hardware keys are still awkward to set up.
- Secretive is the easier way to use Secure Enclave keys (many): Several commenters say the stock tooling is hard to get working and that Secretive provides a clean UI, and they use it for GitHub or VM forwarding. They accept that these keys cannot be backed up.
- Keychain and Secure Enclave features can break silently (some): Commenters cite WireGuard's keychain bug and general keychain consistency problems on macOS as a reason to distrust hardware-backed storage that depends on OS internals.
- Keep a backup key; treat the enclave key as disposable (some): Several people argue that losing a device is the same risk as any hardware token, so a second registered key is required and the enclave key can be considered replaceable.
- Native approach is risky because it is undocumented (a few): One commenter worries that Apple could change or remove the CryptoTokenKit SSH path without notice, since it was never advertised as a supported feature.
- YubiKeys are a better hardware option than Secure Enclave (a few): A user who used YubiKeys for years says they are portable, support touch, and can stay plugged in, while noting the chicken-and-egg problem on new machines and in containers.
- Use PATs or credential helpers instead of SSH for Git (a few): One commenter prefers HTTPS with a PAT and a credential helper like gopass, reserving SSH for commit signing and CI deploy keys.
Links from the comments
- Secretive, the third-party app most commenters recommend for Secure Enclave SSH keys.
- sekey-sh, a small tool that simplifies the SeKey-based setup on macOS 26 and later.
- git-credential-gopass, a credential helper cited as an alternative to SSH for Git operations.
- Commit where WireGuard's macOS app deleted profiles as orphaned after a keychain change.