8 ms·
Native Secure Enclave backed SSH keys on macOS
- greatgib 11mo agoIt's a total pain in the ass to try to have password encrypted gpg or ssh keys in mac. Nothing better that another way to make it even more painful and complicated, so that people will just store plain text keys to not be annoyed.
- traceroute66 11mo ago> It's a total pain in the ass to try to have password encrypted gpg or ssh keys in mac. Who uses password encrypted keys anyway ? No exfiltration protection, and a sitting duck for unlimited automated password guessing attempts. Pre-Tahoe people used Yubikeys or Secretive. But now this native tool is a better option than Secretive, even if Yubikeys still have their uses for the power-users.
- newsoftheday 11mo ago> Who uses password encrypted keys anyway ? Edit: I'm not suggesting an ssh key with a passphrase (or password) is better than what the article suggests; I'm only saying that adding a passphrase (or password) to an ssh key at least buys time to address the situation while the attacker is trying to break the encryption on the stolen key. I am anti-Mac in every way, but I do use passphrase protected ssh keys so if someone were to get a copy of my ssh key, they would have to be able to break the encryption to use the key. I see a lot of devs using blank passphrases on their ssh keys, smh. > sitting duck for unlimited automated password guessing attempts. Using a passphrase on your ssh key has nothing to do with whether the ssh service is configured to allow or deny passwords.
- lloeki 11mo ago> whether the ssh service is configured to allow or deny passwords. Given the consistent use of "password" instead of "passphrase", I think they meant an exfil'ed encrypted key is vulnerable to no-rate-limit bruteforcing, in contrast with hardware-backed keys.
- newsoftheday 11mo agoRight, but my context is that devs often use no passsphrase at all. If someone can get a copy, they have instant access to whatever it has access to. They don't need to even break encryption since the key has none if none has been applied. My stance is simply, at least add a passphrase to the key (though some call it a password).
- lloeki 11mo agogotcha, thanks for clarifying!
- Xylakant 11mo agoThe parent means that an attacker has unlimited attempts at breaking the passphrase on an exfiltrated key. Once the key passphrase is broken, they can log in using the key.
- newsoftheday 11mo agoRight, but my context is that devs often use no passsphrase at all. If someone can get a copy, they have instant access to whatever it has access to.
- fpoling 11mo agoWith an ssh agent and time-bounded key expiration one can have very strong password on the key that is convenient to use. Also password managers like 1password or Bitwarden support ssh-agent protocol so one can have a master password that protects both stored passwords and keys.
- johncolanduoni 11mo agoHow short of a time-bound do you use on your SSH keys?
- fpoling 11mo agoIt is set to 15 minutes due to specifics of automation scripts that we use so they can run uninterrupted.
- manuelabeledo 11mo agoThis looks like the complete opposite, though? It’s easy and provides a convenient way to integrate SSH and TouchID.
- newsoftheday 11mo ago> It's a total pain in the ass to try to have password encrypted gpg or ssh keys in mac I'm anti-Mac but for the year recently that I had to use one at work, no choice...I had no issues, none, using gpg or using a passphrase on my ssh keys.
- tiltowait 11mo agoI've used password-encrypted keys on a Mac plenty of times. It was easy to add them to the SSH agent to not require a password after initial authorization, if that's what I wanted. What is the issue I'm not seeing?
- acdha 11mo agoIt’s been easy since the 2000s. This makes it easier to be safer than the built in SSH agent + Keychain but pure usability was a solved problem around by the turn of the century.
- epistasis 11mo agoWhoa, that is pretty cool. I've been using Secretive for years, and prefer it to all the physical key/card based systems I've tried to get going over the years. I know exactly when my SSH key is used for any operation, because I need to hit a button or do a fingerprint scan. I can keep ssh-agent tunnels to remote boxes so that I can sign git commits remotely without having to worry about a rogue system getting complete access to key ops without me knowing what's going on. However the Tahoe version of secretive is buggy and frequently locks up on initial key op requests. I don't have the bandwidth to debug it and file a bug report, and honesty I'm not sure I want to relearn all that knowledge of SSH to figure it out. I think the smart card SSH UX is worse than secretive's, IIRC my past pain, but if it is reliable, worth a shot.
- lxgr 11mo ago> I can keep ssh-agent tunnels to remote boxes so that I can sign git commits remotely without having to worry about a rogue system getting complete access to key ops without me knowing what's going on. I also really like secretive, but at least this part is not exclusive to it; OpenSSH's `ssh-agent` and `ssh-add` have long supported confirmation of each private key use with `ssh-askpass` (although it unfortunately can't distinguish between remote and local key uses).
- redrove 11mo agonvm
- simonw 11mo agoThis Gist is about not needing to use Secretive any more.
- traceroute66 11mo ago> Secretive has been around for a while, I don't see why it's coming up now through this gist. Because this is different ! Secretive required installation, which is both friction and security-sensitive tool written by a third party. This is native, written by Apple, available out-of-the-box in Tahoe.
- traceroute66 11mo agoAwesome. Won't be ditching Yubikeys just yet but I can see a number of use-cases for this already.
- cedws 11mo agoSecretive is a bit friendlier to set up but I'll probably switch to this anyway so I have one less app on my computer. Plugging my blog post for how to achieve this on Windows 11: https://cedwards.xyz/tpm-backed-ssh-keys-on-windows-11/ https://cedwards.xyz/tpm-backed-ssh-keys-on-windows-11/
- adastra22 11mo agoI’m a bit confused as to why you can export the keys. Can someone explain this?
- jedberg 11mo agoIf I understand correctly, this means you can't back up the private key, correct? It's in the Secure Enclave, so if you lose your laptop, you also lose the key? Since it looks like export only really exports the public key not the private one? Probably not the worst thing, you most likely have another way to get into the remote machine, or an admin who can reset you, but still feels like a hole. Or am I missing something? ps. It amuses me that my Mac won't let me type Secure Enclave without automatically capitalizing it. Edit: I understand good security is having multiple keys, I was simply asking if this one can be backed up. OP answered below and is updating their webpage accordingly.
- aaomidi 11mo agoYou shouldn’t be backing these keys up anyway imo
- justincormack 11mo agoCorrect. Set up multiple keys as backups. Thats also a positive, as nothing can leak the key.
- comprev 11mo agoInability to export the private key is no different from using an YubiKey? You can't "backup" the private key they generate either.
- deleted 11mo ago[deleted]
- johnisgood 11mo agoYeah, that is why you should not [always (depends on your use case)] generate it on a YubiKey. You need to have: - an offline master private key backup (air-gapped) - primary YubiKey (daily use) - backup YubiKey (locked away) - revocation certificate (separate storage) (it is your kill-switch) Having a second YubiKey enrolled is the standard practice. What people do wrong is: - They generate directly on YubiKey - They only use one device - They do not create a revocation certificate - They have no offline backups You generate your GPG keys on a secured system, load the subkeys (not the master because it is not used for daily cryptography) into the YubiKeys, and then remove the secret keys from this system where you generated the keys.
- deleted 11mo ago[deleted]
- procaryote 11mo agoOh, this is neat! I wonder if apple just added support for the secure enclave as a provider or if this might help fix the bad experience of yubikeys on the mac. Last time I tried it, the distributed ssh and ssh-agent didn't play well with security keys
- wahern 11mo agoTime to up my game and finish adding new features to KeyMux, which supports enclave keys for SSH, SSL, and PGP, including in mixed-use scenarios, such as secure enclave-backed SSL peer authentication to a Vault server for SSH authentication with a non-exportable Vault private key: https://keymux.com/ https://keymux.com/ (https://apps.apple.com/us/app/keymux/id6448807557 https://apps.apple.com/us/app/keymux/id6448807557)
- cube2222 11mo agoDoes anybody know if there is something similar for gpg keys? E.g. for commit signing? That is, natively with the Secure Enclave, not exportable.
- fpoling 11mo agoGit commits can be signed with ssh keys.
- jeroenhd 11mo agoUnfortunately I've found that not every source management tool understands SSH signatures and using them may have your commits end up being shown as signed by an untrusted key. On Linux, GPG supports TPM2, but I'm not sure if that also works on macOS.
- jabberwhookie 11mo agoYou can (mis)use ssh keys for git signing, but GPG on gpg-card and S/MIME on PIV card are the two standards and their respective hardware implementations (for signing keys in general.)
- moooo99 11mo agoSome Fido2 keys like the YubiKey and Nitrokeys support PGP keys as well. Works pretty nice as well and has the added bonus of your key not being tied to a pice of hardware that is as likely to break like a laptop (or be upgraded on a semi-regular basis)
- rkeene2 11mo agoSee my comment above regarding Keeta Agent, which supports GPG and SSH with the same key.
- berzan 11mo agoThis is just so perfect. No longer a 3rd party glue and separate ssh agent is needed.
- redleader55 11mo agoThis exists: https://github.com/facebookincubator/sks https://github.com/facebookincubator/sks. It's a golang library that abstracts usage of ssh keys backed by hardware on all sorts of devices - mostly designed for laptops, but supports Linux, Windows and MacOs
- euroderf 11mo agoHow can I get such a key into my iPhone too, so that I can sign emails and file and such with the same private key when I'm on my phone, and my public key is valid for all such operations ? Will iCloud take care of that ? And then I want it all usable from my (multiple) email clients...
- arianvanp 11mo agoThese aren't synced over iCloud What you're thinking of are Passkeys. Which are synced. Somebody would have to write an SecurityKeyProvider that talks to the Passkey API instead. Actually I don't think it's completely impossible. The only thing is that passkeys are origin-bound. They belong to a specific AppBundle ID or domain name. If say Secretive would add passkey support then that specific public/private keypair can't be used by another app. Though it does sync across instances of the app across devices.
- akerl_ 11mo agoThis is for SSH, not GPG.
- euroderf 11mo agoClearly I'm hazy on this stuff. But if I can export the private key from my Mac, is there any use for it on my iPhone, and any way to get it in there ?
- euroderf 11mo agoI guess it would depend on having an SSH app with the right feature ? (import private key, transfered in encrypted form)
- watermelon0 11mo agoDoes anybody know why 'p-384-ne' (instead of 'p-256-ne') cannot be used? Key can be generated, but 'ssh-keygen -w /usr/lib/ssh-keychain.dylib -K -N ""' cannot find the key to export.
- arianvanp 11mo agoI think this is an openssh limitation. openssh only supports sk-ecdsa-sha2-nistp256 and sk-ed25519 security keys iirc
- jcalvinowens 11mo agoDoes the hardware only support the NIST curves? Or is that just the example that happens to be given?
- arianvanp 11mo agoOnly supports NIST curves and ECDSA yes. I've heard people make the point before that EdDSA is not great for secure enclaves due to being suspictable to Fault Attacks which could lead to (partial) key extraction
- jcalvinowens 11mo agoI don't trust the NIST curves: they were generated in a dubious way which has been written about extensively elsewhere (the coefficients for P-256 were generated by hashing the unexplained seed c49d360886e704936a6678e1139d26b7819f7e90). I always avoid them unless I have to use them. It makes me sad when hardware forces me to use them. > I've heard people make the point before that EdDSA is not great for secure enclaves due to being suspictable to Fault Attacks which could lead to (partial) key extraction Huh, got a link? My understanding is that eddsa is better with respect to side channels in every way, that was part of the intent of it's design. I've worked with crypto hardware which supports it.
- arianvanp 11mo agohttps://romailler.ch/project/eddsa-fault/ https://romailler.ch/project/eddsa-fault/ I think this can be solved by using hedged eddsa (Signal does this)
- deleted 11mo ago[deleted]
- WhereIsTheTruth 11mo agoI would not trust it personally, specially since the Chip Security Act is looming https://www.centerforcybersecuritypolicy.org/insights-and-research/congress-proposed-chip-security-act-threatens-to-create-new-cyber-vulnerabilities-in-u-s-semiconductors https://www.centerforcybersecuritypolicy.org/insights-and-re...
- johncolanduoni 11mo agoIf the Secure Enclave on your Mac is backdoored, the fact that the key from your Yubikey (or whatever HSM) is un-extractable will be a very cold comfort.
- WhereIsTheTruth 11mo ago-2 after France admitted Apple and Google devices are backdoored classic hackernewers
- adastra22 11mo agoIs there a way to make the lifetime of the key last more than a year?
- metafunctor 11mo agoThe key itself appears to have no validity period, the validity period is only for the certificate made for the key. Maybe you could create a CSR for the key/identity and then sign it with your own CA (or self-sign with openssl) for whatever validity period you like. Then `sc_auth import-ctk-certificate`.
- daft_pink 11mo agoWhy would you want the private key file if you store it within the secure enclave?
- lxgr 11mo agoProbably for the same reason that OpenSSH's `sk` implementation also still needs a private key file (even for the "resident key" option): You need to be able to point OpenSSH's various tools to something in an identity context, and that something traditionally is a private key file. The article even mentions that it doesn't contain any sensitive data: > Note that the "private" key here is just a reference to the FIDO credential. It does not contain any secret key material. It's a slightly different story for non-resident `sk`-backed keys; these actually require the private key file since the hardware authenticator itself is (or at least can be) stateless. (It's still not a security risk if it ever leaks, but it's an availability risk if it's ever lost.) Not sure if macOS's backing implementation is stateful or stateless (or some unfortunate hybrid of both; i.e., it might just store a stateful wrapped key in some system-level keychain in a way that intransparently breaks if the OS is ever reinstalled, but also doesn't allow querying an intact system for any existing credentials).
- daft_pink 11mo agoThanks I missed this in the description.
- rkeene2 11mo agoIf you're willing to go a bit further you can also do GPG signing with ECDSA, though it requires a patched GPG due to bugs and a patched SSH agent that allows raw signing. We have a packaged version with a macOS UI [0], but the same backend [1] works on Linux using the tpm via PKCS#11. We have a blog post on this, but I guess it was never made public, but the only difference between GPG and SSH is the way in which keys and signatures are wrapped and listed through the various layers -- it's all just fundamentally ECDSA with a named curve. [0] https://github.com/KeetaNetwork/agent https://github.com/KeetaNetwork/agent [1] https://github.com/KeetaNetwork/agent/tree/main/Agent/gnupg/src https://github.com/KeetaNetwork/agent/tree/main/Agent/gnupg/...
- ikiris 11mo agoIts worth noting that this is the likely NSA backdoored curve under the hood and probably should not be used.
- dhosek 11mo agoThis may be the thing to get me to upgrade to MacOS 26.
- acdha 11mo agoIt’s not new to Tahoe. I use it on Sequoia.
- vmodel_ai 11mo agoIt feels pretty good.
- varenc 11mo agoside note: It's interesting that the `sc_auth` CLI tool to create the SSH key, is just a bash script! It seems truly ancient, and has comments referencing mac OS Tiger (20+ years old) and non-existent files from old macOS. It calls out to '/System/Library/Frameworks/CryptoTokenKit.framework/ctkcard' (not on PATH) to actually create the ssh key.
- rtyu1120 11mo agoThe command is available on Sequoia too!
- larusso 11mo agoOk I wished for this kind of feature for years. I started using a yubikey with an ssh key via gpg ssh-agent in 2018 or 2019. When resident ssh keys came around I switched over to FIDO2 based keys on my yubikey. The main issue with both was the fact that the default ssh setup wasn’t working anymore. One needs extra configs and more commands to get to the public key etc. Yubikey’s are great but block an USB port. And then there is the age old question for me: One SSH key per User for all services? One key per machine for all services? Or one key per service? This year I started to play around with the 1Password ssh-agent feature (bit warden has it as well as far as I know) If you're ok with allowing all your keys being listed in the agent this works pretty easy out of the box. I never liked the fact that the default recommended way to use ssh is to use an agent that just has multiple keys which can be tested one after another and in most cases stay unlocked there after first use for the rest of the session. I configured around to make sure that I explicitly use one key for one specific service. But that is sadly extra configuration etc etc.
- atmosx 11mo agoI believe that in 1Passwd you can define / preselect a key per host now. So you can pinpoint key -> host. Some hosts have firewall rules that will block after X attempts were X might be low. However the agent still has access to all your keys, obviously.
- sisk 11mo agoThanks for this info. First I'd heard of it. Here's a link for others. https://developer.1password.com/docs/ssh/bookmarks/ https://developer.1password.com/docs/ssh/bookmarks/
- larusso 11mo agoAh cool. I worked around by storing the public keys in my dot repo and use the identity file ssh config option for said host. Great if I don’t have to do this anymore. Next level config madness: Use different ssh keys per GitHub org ;).
- j0hnM1st 11mo agoFundamental services like DNS, which was designed as distributed going down was the cause last 2 outages and really need to think of alternatives methods to ensure resilience. Shift left, design better.
- big-and-small 11mo agoBot comment? Or wrong tab? Moderators?
- burnt-resistor 11mo agoThis isn't such a great idea for personal SSH or GPG keys that should be locked away in physical hardware thing that need to be moved to other devices/machines. What security processors are great for is corporate machine, system/service, and user key management IdM/MDM processes that need secret storage. Furthermore, with portable devices like Yubikey it's possible to create a master Certify-only GPG key where the sub Signature/Encryption/Authentication-subkeys live on the Yubikey. The encrypted C private key part with the S/E/A stubs still needs to be backed-up to some durable, versioned storage that isn't tied to one device. Finally, use GPG for SSH. And definely avoid file-based SSH local private key management for wherever possible for anything substantial because it doesn't scale well.
- acdha 11mo ago> This isn't such a great idea for personal SSH or GPG keys that should be locked away in physical hardware thing that need to be moved to other devices/machines I would change this: it’s great for personal usage BUT you should always use n>1 keys to avoid being locked out. For example, using the Secure Enclave for your daily use is fine but you’d want to have, say, a FIDO2 hardware key setup so if your laptop fails or is reset you can get into anything where you use that key.
- jwr 11mo agoThis is a good moment to remind everyone of this excellent guide: https://github.com/drduh/YubiKey-Guide https://github.com/drduh/YubiKey-Guide it describes how to use your YubiKeys (please always use at least two, so that you have a backup) for GnuPG keys and SSH. I've been using this setup since 2018 and it is brilliant. I know GnuPG is not in fashion these days, but thanks to this setup I have SSH logins using YubiKeys, encrypted backups using GnuPG, and 2-factor authentication for a number of sites that support Webauthn. All with backup keys, which is IMPORTANT: do not get locked into using a single device, because sooner or later you will lose that device or it will suddenly die.
- n0ot 11mo agoThis seems really cool. I use Secretive and would like to switch to this native solution. The one thing holding me back is that I like that Secretive allows you to create keys that don't require TouchID, yet still notifies you when they are used. I use an external keyboard, so reaching for the fingerprint reader isn't as easy as it would be if I just used the internal keyboard. Fine, ControlMaster is a good compromise. Except when git signing (every commit) is a requirement, you have to touch the reader every, single, time. That's fine when making routine commits, not so when rebasing. Ideally, I could tell the SecureEnclave to notify me, but don't require biometrics for the next 30 seconds or so, but since that's not a thing, that I'm aware of, I'd at least like to know when my git signing key is being used.
- deleted 11mo ago[deleted]