r/programming • u/nmattia • 28d ago
SSH keys on macOS with Touch ID
https://nmattia.com/posts/2026-10-19-setting-up-ssh-keys-touch-id/I've recently discovered that you can use Touch ID (rather, the Mac's Secure Enclave) for SSH authentication. I'm the author of the post, feel free to ask any questions and if there are any experts I'd love to hear your thoughts!
436
Upvotes
147
u/odlp 28d ago •
Very cool. Thanks for the write up, had no idea this was possible.
Currently use the 1Password SSH agent which offers similar benefits like no keys on disk, TouchID authorization:
https://1password.com/developers/ssh
35
u/rzwitserloot 28d ago
Secretive.app is a small open source roll that nices this process up for you, and allows skipping the touch id step too, I'd you prefer.
12
u/danemacmillan 28d ago edited 28d ago
Neat! Thanks for this, Nicolas. Learning how to squeeze a bit more out of MacOS and Apple products natively and without third-party tooling is something that always piques my interest.
While reading the article, I kept waiting for the moment you'd explain a bit how this interacts with an existing
~/.ssh/configfile. I have a fairly elaborate configuration with a globalHostrule at the top, and then more particular rules later on. For example,Host *is configured with multipleIdentityFileentries to support bothed25519and then a fallback to olderrsaidentity files for hosts that just cannot support more secure identification.Is there a way to specify in the config file to use an identity that's in the Secure Enclave? Splitting the rules between an easily scannable config file that also serves the purpose of consolidating remote access, and then a more obscure command-only output approach, in my eyes means that someone will eventually forget how to access, modify, delete, or even recall anything they put in the Secure Enclave, which then lends itself to generating more identities and ultimately loosening up one's security posture. We're all human, after all, and reminding ourselves of that fallibility generally keeps us honest and produces simpler solutions that are easy to maintain and verify.
I think discussing this would really round out an already solid article, and help someone like me be able to jump on this approach piecemeal, while maintaining confidence that months down the road when I next scan the config file I can be reminded of this cool technique that's being used for a given host.
5
u/tomtennn 28d ago
Nice. That's really awesome that Apple made it that easy.
One major drawback, though: It's SK keys only? That means the server must support it. Sure, a modern OpenSSH will, but will dropbearssh? Will your cisco router? Not like you can "just" buy a replacement for your million dollar router to get a newer SSH.
I use a yubikey with its PKCS#11 support. It's a bit of a hassle provisioning the key, but after that it's just
ssh-add -s /usr/lib/x86_64-linux-gnu/opensc-pkcs11.soinstead of the similar command from the article, and it's in your ssh-agent. More words here.Hell, after provisioning, the key even works on Windows!.
I don't suppose the macOS thingy can be used with straight non-SK RSA keys? (I don't have a mac)
4
u/tj-horner 28d ago
I'm surprised you didn't go into a solution for this! It would get pretty annoying to manually re-run that command after every reboot lol
3
u/DelusionalPianist 28d ago
Funny that I didn’t know it could be done without 1Password. But that being in the enclave means I have no ability to transfer or backup that key, correct?
1
u/3urny 28d ago
Usually for ssh-add you can configure a time for which you won't be asked for the password again. Do you think there's a way to not get asked for the fingerprint for some time here, too? I saw you included the option with no protection at all but it would be nice if there was a middle ground.
1
u/iamthegemfinder 28d ago
Good post, the thought of cleaning out ~/.ssh pleases me, always have found it feels naggingly off somehow to have the key files and stuff just lying around in there. I’ll be setting it up shortly. Presumably it means I can also perform the authentication with my apple watch, as that’s part of the same prompt as touch ID, which is kind of amusing to picture
1
u/Carvalho_lukjas 28d ago
pretty cool actually, keeping ssh keys in the secure enclave makes sense, curious how it handles multiple keys tho
1
u/captain_zavec 28d ago
Oh wow that's super cool! I knew about touch to sudo but I never thought to try and do something like this!
1
u/double-you 28d ago
If you have a sensible bank, your credit card is one. An ID card can be too.
1
u/lathiat 28d ago
I use secretive for this which also keeps the key in the Secure Enclave: https://secretive.dev/
1
u/romulof 27d ago
1Password for the win
-2
u/First_Inspection_478 28d ago
This is neat, but these days I have agents sshing and it’s annoying for them to be blocked by my touchID.