The standard workaround for using Apple's Secure Enclave Processor (SEP) for SSH keys has always been the agent. Tools like Secretive keep the private key locked inside the SEP and run a proxy agent that OpenSSH talks to. But the developers behind LogRaker, a macOS log viewer, decided that architecture was unnecessary bloat. They built an app that speaks SSH directly through swift-nio-ssh, allowing the application to hand the Secure Enclave key straight to the SSH library without an intermediary agent.

The Hardware Is The Vault

The core advantage here is physical security. A key generated in the Secure Enclave is created inside a separate processor and the private half never leaves that silicon. It cannot be copied, exported, or read by macOS or any app. The key returned by CryptoKit is essentially just a handle; the dataRepresentation is an opaque blob that only works on the specific Mac that generated it. Lose that handle, and the key is gone forever, because the SEP doesn't keep a ledger of every key it has ever made.

Implementation Gotchas

While the cryptography is handled by the hardware, the application logic is where the bodies are buried. The developer noted a critical ordering failure in early builds: saving the key handle to the keychain after deploying the public key to the server. If the save failed, the server trusted a key that didn't exist locally, with no way to revoke it. The fix was to save the handle first, then deploy, and delete the handle if the deployment was cancelled. Another trap involved iCloud syncs; if a non-SEP Mac (like an older Intel model) synced a preference for a Secure Enclave key, it broke sign-in on other machines. The app now detects these hardware limitations and keeps the setting local rather than propagating it.

Key Takeaways

  • No Agent Required: By implementing SSH via swift-nio-ssh, apps can interact with SecureEnclave.P256.Signing.PrivateKey directly, bypassing the ssh-agent dependency entirely.
  • Handle Hygiene: The dataRepresentation blob is the only record of the key. It must be stored locally (Keychain) and never synced to iCloud, as it is useless on other machines.
  • Silent Signing: The app uses .privateKeyUsage access control, allowing signatures without Touch ID prompts to prevent background reconnection failures during server restarts.
  • Hardware Fallbacks: Code must gracefully handle Macs without Secure Enclave support, ensuring that configuration syncs don't break authentication on unsupported devices.

The Bottom Line

This is how you build for the hardware, not just the OS. Relying on agents is a crutch for software that can't talk to the kernel properly; LogRaker proves that direct integration is cleaner, safer, and significantly less annoying for 3 a.m. log streams.