<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>nmattia.com</title>
  <link>https://aggr.aymericbeaumet.com/sources/nmattia.com/</link>
  <description>Browse aymeric&#39;s, an independent, searchable archive of readable snapshots from followed feeds, preserved in Git with aggr.</description>
  <language>en</language>
  <atom:link href="https://aggr.aymericbeaumet.com/sources/nmattia.com/rss.xml" rel="self" type="application/rss+xml"/>
  <lastBuildDate>Tue, 20 Oct 2026 10:23:58 +0000</lastBuildDate>
  <generator>aggr</generator>
  <item>
    <title>Setting up SSH keys on macOS with Touch ID</title>
    <link>https://aggr.aymericbeaumet.com/items/lobste-rs/2026-10-20-setting-up-ssh-keys-on-macos-with-touch-id/</link>
    <guid isPermaLink="false">urn:aggr:item:7619eb41d70e0d63ab811292d32c75ce19227885</guid>
    <atom:link href="https://nmattia.com/posts/2026-10-19-setting-up-ssh-keys-touch-id/" rel="via" type="text/html"/>
    <pubDate>Tue, 20 Oct 2026 10:23:58 +0000</pubDate>
    <dc:creator>nmattia.com by nmattia</dc:creator>
    <description>Comments</description>
    <content:encoded>&lt;hr /&gt;
&lt;p&gt;&lt;picture class=&quot;article-picture article-picture-fallback&quot; style=&quot;--image-ratio:16 / 9&quot;&gt;&lt;img src=&quot;https://nmattia.com/_astro/touch-id-button.CmOAUBec_25NwAs.webp&quot; alt=&quot;Blog post social card&quot; loading=&quot;eager&quot; decoding=&quot;async&quot; fetchpriority=&quot;high&quot; referrerpolicy=&quot;no-referrer&quot; class=&quot;progressive-image&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;In the first part of this post I’ll show a simple, secure way to create an SSH key on Mac (it’s 3 commands, including support for GitHub). In the second part I’ll dig deeper and explain what’s actually happening for the curious reader.&lt;/p&gt;
&lt;p&gt;Macs have a built-in so-called &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://support.apple.com/en-gb/guide/security/sec59b0b31ff/web&quot;&gt;Secure Enclave&lt;/a&gt;, where we can create “identities” that simply cannot be stolen (unless maybe you’ve made enemies with a nation state). Those identities are protected with Touch ID and can be used for SSH authentication. There are some great benefits about using this over traditional SSH key files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The private material cannot be extracted, is never shown, cannot be stolen,&lt;/li&gt;
&lt;li&gt;You get prompted whenever the identity is used,&lt;/li&gt;
&lt;li&gt;No key files (like &lt;code&gt;~/.ssh/id_ed25519.pub&lt;/code&gt; and friends) littering the file system; and there’s no risk of mistakenly deleting them either.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This extra security will be in effect whenever you use SSH, including git-over-ssh like GitHub. It’s great that advanced security tech is available by default on some of the most widely distributed computers in the world! A few years ago stuff like this could only be found at CERN and/or in Dan Brown novels. Let’s see how it can be set up on your consumer-grade Mac.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It is essential that the human interface be designed for ease of use, so that users routinely and automatically apply the protection mechanisms correctly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Saltzer and Schroeder, “The Protection of Information in Computer Systems”&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Quick Setup&lt;/h2&gt;
&lt;p&gt;We’ll create a secure identity on the Secure Enclave, then tell SSH how to use it for authentication, and finally add the key to GitHub.&lt;/p&gt;
&lt;h3&gt;Step 1: create the identity that you’ll use on this Mac:&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;code-snippet&quot; data-language=&quot;Shell&quot;&gt;&lt;span class=&quot;syntax-source syntax-shell syntax-bash&quot;&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-function syntax-shell&quot;&gt;sc_auth&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-arguments syntax-shell&quot;&gt; create-ctk-identity&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;l&lt;/span&gt; ssh-key&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;k&lt;/span&gt; p-256-ne&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;t&lt;/span&gt; bio &lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt; run once to create identity&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You’ll be prompted to touch “Touch ID”. Your identity is now created and saved securely (parameters are explained in the &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://nmattia.com/posts/2026-10-19-setting-up-ssh-keys-touch-id/#under-the-hood&quot;&gt;deep dive&lt;/a&gt; below).&lt;/p&gt;
&lt;h3&gt;Step 2: tell SSH to use the identity (when prompted for a PIN, just hit enter):&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;code-snippet&quot; data-language=&quot;Shell&quot;&gt;&lt;span class=&quot;syntax-source syntax-shell syntax-bash&quot;&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-function syntax-shell&quot;&gt;ssh-add&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-arguments syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;K&lt;/span&gt;&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;S&lt;/span&gt; /usr/lib/ssh-keychain.dylib &lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt; run after a reboot&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From here on, SSH will know to use the identity from the Secure Enclave when connecting via SSH; it does not have a good memory so you’ll need to remind it after a reboot.&lt;/p&gt;
&lt;h3&gt;Step 3: Whenever you need to register your key to a new server (like GitHub), run this command:&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;code-snippet&quot; data-language=&quot;Shell&quot;&gt;&lt;span class=&quot;syntax-source syntax-shell syntax-bash&quot;&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-function syntax-shell&quot;&gt;ssh-add&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-arguments syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-parameter syntax-option syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-parameter syntax-shell&quot;&gt; -&lt;/span&gt;L &lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt; run when you need the public key&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If multiple identities are listed, use the line that starts with &lt;code&gt;sk-ecdsa-sha2-nistp256...&lt;/code&gt;. It’s a shareable handle for the identity, and this is the SSH key that GitHub will ask about.&lt;/p&gt;
&lt;p&gt;&lt;picture class=&quot;article-picture article-picture-fallback&quot; style=&quot;--image-ratio:16 / 9&quot;&gt;&lt;img src=&quot;https://nmattia.com/_astro/github-and-public-keys.DDyiYt-R_1qoNBw.webp&quot; alt=&quot;image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;low&quot; referrerpolicy=&quot;no-referrer&quot; class=&quot;progressive-image&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The output of &lt;code&gt;ssh-add -L&lt;/code&gt; can be added as a GitHub SSH Key&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s all you need for a super secure setup! The new identity can now be used with SSH, and you’ll be prompted for Touch ID during authentication:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;code-snippet&quot; data-language=&quot;Shell&quot;&gt;&lt;span class=&quot;syntax-source syntax-shell syntax-bash&quot;&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-shell&quot;&gt;&lt;span class=&quot;syntax-variable syntax-function syntax-shell&quot;&gt;git&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-meta syntax-function-call syntax-arguments syntax-shell&quot;&gt; push &lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;&lt;span class=&quot;syntax-punctuation syntax-definition syntax-comment syntax-begin syntax-shell&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt; triggers Touch ID prompt&lt;/span&gt;&lt;span class=&quot;syntax-comment syntax-line syntax-number-sign syntax-shell&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No one can steal your identity (well, you can’t even give it away willingly since it can’t be extracted from the Secure Enclave), but with great powers etc: if your Mac dies, so does the identity, and you’ll need to create a new one (and re-register it where necessary, like GitHub).&lt;/p&gt;
&lt;p&gt;&lt;picture class=&quot;article-picture article-picture-fallback&quot; style=&quot;--image-ratio:16 / 9&quot;&gt;&lt;img src=&quot;https://nmattia.com/_astro/git-clone-touch-id.C4ZD3wi0_1VhtPk.webp&quot; alt=&quot;image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;low&quot; referrerpolicy=&quot;no-referrer&quot; class=&quot;progressive-image&quot;&gt;&lt;/picture&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You’ll get a Touch ID prompt when git tries to authenticate with SSH&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you’re curious about how this works, read on!&lt;/p&gt;
&lt;h2&gt;Under the hood&lt;/h2&gt;
&lt;p&gt;We’ll now try to understand what happens under the hood. We’ll start with the actual identity creation in the Secure Enclave, then look at how SSH is allowed to interface with the Secure Enclave with &lt;code&gt;ssh-keychain.dylib&lt;/code&gt;, and then try to see what happens in a complete SSH sign-in flow.&lt;/p&gt;
&lt;p&gt;This is the result of reading posts (like &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://gist.github.com/arianvp/5f59f1783e3eaf1a2d4cd8e952bb4acf&quot;&gt;this great investigation by &lt;code&gt;arianvp&lt;/code&gt;&lt;/a&gt;), manual pages, and experimentation. A lot of this is undocumented, and this is the minimum information I needed to form a mental model of what’s happening and convince myself that it does, indeed, work.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Some of the command outputs below have been trimmed for legibility, I invite you to run them locally if you want the full experience!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Creating an identity on the Secure Enclave&lt;/h3&gt;
&lt;p&gt;Identities are managed with the &lt;code&gt;sc_auth&lt;/code&gt; command (where &lt;code&gt;sc_&lt;/code&gt; stands for Smart Card). In Apple-speak, they are “CryptoTokenKit” identities, or CTK identities for short. Why not Smart Card Identities? What is a Smart Card? No idea! There’s a lot of weird Apple vocabulary, but in practice they’re just private keys stored on the Secure Enclave:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;$ sc_auth list-ctk-identities
Key Type Public Key Hash                          Prot Label
p-256-ne 458F712F281B53C683F23FC02E69D44DAFDAA3DE bio  ssh-key
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you followed along in the &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://nmattia.com/posts/2026-10-19-setting-up-ssh-keys-touch-id/#quick-setup&quot;&gt;Quick Setup&lt;/a&gt;, you should have exactly one identity here, that was created when you ran the &lt;code&gt;sc_auth create-ctk-identity&lt;/code&gt; command. Let’s look at the &lt;code&gt;create-ctk-identity&lt;/code&gt; command in more detail:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;sc_auth create-ctk-identity -l &amp;lt;label&amp;gt; -k &amp;lt;key type&amp;gt; -t &amp;lt;protection&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When using the &lt;code&gt;p-256-ne&lt;/code&gt; key type, this command creates the identity on the Secure Enclave — I’m guessing by first gathering some entropy, then generating some private key material and allocating whatever it needs for bookkeeping and ensuring it can only be accessed with your fingerprint.&lt;/p&gt;
&lt;p&gt;The label is freeform and just a note attached to the key. The key type is a cryptographic setting (the elliptic curve used). At the time of writing, the following values are accepted: &lt;code&gt;p-256|p-384|p-521|p-256-ne|p-384-ne&lt;/code&gt;. The &lt;code&gt;-ne&lt;/code&gt; suffix means “Non-Extractable”, meaning the key is generated by the enclave itself and &lt;em&gt;cannot&lt;/em&gt; be extracted from the Secure Enclave. For SSH we only need &lt;em&gt;signing&lt;/em&gt;, which is done by (and &lt;em&gt;on&lt;/em&gt;) the Secure Enclave itself, and at no point do we need (or want) to export the private key. The &lt;code&gt;p-384&lt;/code&gt; curve is not supported by (Open)SSH, so this narrows it down to &lt;code&gt;p-256-ne&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally, &lt;code&gt;protection&lt;/code&gt; can be either &lt;code&gt;bio&lt;/code&gt; or &lt;code&gt;none&lt;/code&gt;. When set to &lt;code&gt;bio&lt;/code&gt;, using the key requires biometrics (like Touch ID). With &lt;code&gt;none&lt;/code&gt;, the key &lt;em&gt;still&lt;/em&gt; cannot be extracted (i.e. stolen) &lt;em&gt;but&lt;/em&gt; programs would be able to silently use SSH; I recommend using &lt;code&gt;bio&lt;/code&gt;, but YMMV; if you get annoyed by the Touch ID prompts whenever you &lt;code&gt;git pull&lt;/code&gt;, you might want to use &lt;code&gt;none&lt;/code&gt; here.&lt;/p&gt;
&lt;p&gt;Now that we have some elusive identity on the Secure Enclave, let’s see how we can tell SSH to use it for authentication.&lt;/p&gt;
&lt;h3&gt;Translating between SSH and the Secure Enclave&lt;/h3&gt;
&lt;p&gt;There’s a bit of impedance mismatch, and &lt;code&gt;ssh&lt;/code&gt; doesn’t know how to use the identity by default:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;$ ssh -T git@github.com
git@github.com: Permission denied (publickey).
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The SSH agent cannot use the Secure Enclave identities as-is, but Apple has us covered with a small translation layer in the form of &lt;code&gt;ssh-keychain.dylib&lt;/code&gt;, a &lt;code&gt;dlopen&lt;/code&gt;-able library available natively on all recent macOS versions:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;$ ssh-add -K -S /usr/lib/ssh-keychain.dylib
...
Resident identity added: ECDSA-SK SHA256:QZ+Cx6/AkS9sek9INtsXt6t7wuHOtA555CLJu8a8V7w
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we’re relying on &lt;code&gt;ssh-add&lt;/code&gt;’s built-in support for FIDO-style authenticator via the &lt;code&gt;-K&lt;/code&gt; parameter. This lets the SSH agent know that it shouldn’t read a standard private key (for instance &lt;code&gt;~/.ssh/id_ed25519&lt;/code&gt;) but that it should expect the keys to be stored “externally” (for a lack of better words). With &lt;code&gt;-K&lt;/code&gt; alone, &lt;code&gt;ssh-add&lt;/code&gt; would look for public keys on USB devices (think YubiKey); though we can customize this behavior by registering a “security key provider” with &lt;code&gt;-S &amp;lt;provider&amp;gt;&lt;/code&gt;. This provider should be a stateless dynamically-loadable library, which is exactly what &lt;code&gt;/usr/lib/ssh-keychain.dylib&lt;/code&gt; is. The interface is not documented (at least not in a way I was able to meaningfully process), but we can have a look at what &lt;code&gt;ssh-keychain.dylib&lt;/code&gt; exposes:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;$ dyld_info -exports /usr/lib/ssh-keychain.dylib
/usr/lib/ssh-keychain.dylib:
    -exports:
        offset      symbol
        0x00001A2C  _C_GetFunctionList
        0x00000F30  _sk_api_version
        0x00000F38  _sk_enroll
        0x0000136C  _sk_load_resident_keys
        0x00000F40  _sk_sign
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Most likely, &lt;code&gt;_sk_load_resident_keys&lt;/code&gt; is meant to return a list of (public keys of) identities, and &lt;code&gt;_sk_sign&lt;/code&gt; will sign a payload using a specified identity (here, resident means “residing on e.g. the Secure Enclave”).&lt;/p&gt;
&lt;p&gt;We’ve seen how the identities can be created on the Secure Enclave, and how they can, in theory, be used by the SSH agent. Let’s put this to the test and see what happens when an SSH connection is created.&lt;/p&gt;
&lt;h3&gt;SSH Sign-in flow with the ssh-keychain provider&lt;/h3&gt;
&lt;p&gt;Let’s see what we need for authenticating to a remote SSH server. At all times, the SSH agent needs (1) a list of (public) keys that can be used to authenticate, and (2) a way to prove to a server that it has the corresponding private key for any of those keys.&lt;/p&gt;
&lt;p&gt;When &lt;code&gt;ssh-add&lt;/code&gt; is first called with &lt;code&gt;-S &amp;lt;provider&amp;gt;&lt;/code&gt;, the &lt;code&gt;_sk_load_resident_keys&lt;/code&gt; routine is called, which returns the public keys of all resident keys on the FIDO-style authenticator. Those are stored in the SSH agent (alongside their corresponding provider, namely &lt;code&gt;ssh-keychain.dylib&lt;/code&gt;) and will later be offered as candidates to any remote SSH server we try connecting to. (Also now that the SSH agent knows about the Secure Enclave identity we created earlier, we can view its SSH-style public key with &lt;code&gt;ssh-add -L&lt;/code&gt;.)&lt;/p&gt;
&lt;p&gt;Let’s say an SSH connection is initiated: the remote accepts one of those public keys offered by the agent and “challenges” the client to prove its identity. The agent calls &lt;code&gt;_sk_sign&lt;/code&gt; to create a signature with the private key (matching the accepted public key) and the challenge (roughly speaking). This will be forwarded to the Secure Enclave, prompt Touch ID, and if approved, will return a signature for the challenge. The signature is forwarded back to the server, which can confirm we — the client — have the corresponding private key.&lt;/p&gt;
&lt;p&gt;Let’s see what this looks like in practice:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;&lt;span class=&quot;code-snippet&quot;&gt;$ ssh -T git@github.com
git@github.com: Permission denied (publickey).
$ ssh-add -K -S /usr/lib/ssh-keychain.dylib
Enter PIN for authenticator:
Resident identity added: ...
$ ssh -vvv -T git@github.com
debug1: get_agent_identities: agent returned 1 keys
debug1: Offering public key: ssh: ECDSA-SK SHA256:QZ+Cx6/AkS9sek9INtsXt6t7wuHOtA555CLJu8a8V7w authenticator agent
debug1: Server accepts key: ssh: ECDSA-SK SHA256:QZ+Cx6/AkS9sek9INtsXt6t7wuHOtA555CLJu8a8V7w authenticator agent
debug3: sign_and_send_pubkey: signing using sk-ecdsa-sha2-nistp256@openssh.com SHA256:QZ+Cx6/AkS9sek9INtsXt6t7wuHOtA555CLJu8a8V7w
&amp;lt;at this point, Touch ID prompt appears&amp;gt;
Authenticated to github.com ([20.250.119.67]:22) using &amp;quot;publickey&amp;quot;.
Hi nmattia! You&amp;#39;ve successfully authenticated, but GitHub does not provide shell access.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;ssh&lt;/code&gt; debug logs show that one key is offered by the agent, accepted, and then used to create a signature. After the server has verified the signature, authentication is granted (although &lt;code&gt;GitHub does not provide shell access&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;One note: whenever we register the identity with the SSH agent, &lt;code&gt;ssh-add&lt;/code&gt; prompts us for a PIN. What gives? Why does entering an empty PIN work, isn’t this mighty unsafe‽&lt;/p&gt;
&lt;p&gt;Well, no, it’s not unsafe! When we tell &lt;code&gt;ssh-add&lt;/code&gt; to use a FIDO-style authenticator, I suspect its default behavior is to ask for a PIN as it assumes we’ll be using a USB, YubiKey-style authenticator; only we shortcut the whole thing with &lt;code&gt;ssh-keychain.dylib&lt;/code&gt; (and the security comes not from a PIN, but from the soft skin under your fingertips; much cooler). Not great in terms of usability, but &lt;em&gt;I guess&lt;/em&gt; it makes sense. (I have no idea what would happen if you have more than one FIDO authenticator; go &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://github.com/sponsors/nmattia&quot;&gt;support me on GitHub&lt;/a&gt; and I’ll buy a collection of YubiKeys to experiment).&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Let’s recap: we can use a somewhat cryptic, poorly documented “Smart Card” tool to create a “CryptoTokenKit” identity on the “Secure Enclave”. Then, by using the poorly documented &lt;code&gt;ssh-keychain.dylib&lt;/code&gt;, we can use said identity to generate signatures that Apple’s &lt;code&gt;ssh&lt;/code&gt; can use. There’s no guarantee that all this missing documentation wouldn’t say “Do not use this; terribly unsafe in practice”, but hey: all this security talk by Apple, they wouldn’t lie to us, right? &lt;em&gt;*spooky*&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Joke aside, it’s pretty cool to have sci-fi style security modules baked into most modern devices; the more people start using them and pushing for openness, the better the support from the companies will be. We can have nice things!&lt;/p&gt;
&lt;p&gt;Again, a lot of this was derived from &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://gist.github.com/arianvp/5f59f1783e3eaf1a2d4cd8e952bb4acf&quot;&gt;this gist&lt;/a&gt;; highly recommend having a read and potentially asking questions in the discussion.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://bsky.app/profile/nmattia.bsky.social&quot;&gt;Let me know&lt;/a&gt;&lt;em&gt;or&lt;/em&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://lobste.rs/s/d7m5j1/setting_up_ssh_keys_on_macos_with_touch_id&quot;&gt;join the discussion&lt;/a&gt;&lt;/em&gt; if you enjoyed this article! You can also &lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://buttondown.com/nmattia&quot;&gt;subscribe&lt;/a&gt; to receive updates.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Here&#39;s more on the topic of macOS:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://nmattia.com/posts/2026-01-13-using-luks-on-macos/&quot;&gt;Accessing LUKS and ext4 drives from macOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot; href=&quot;https://nmattia.com/posts/2022-07-12-keep-you-mac-awake-with-caffeinate/&quot;&gt;Keep your Mac awake with caffeinate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content:encoded>
    <category>news</category>
    <category>cryptography</category>
    <category>mac</category>
    <category>security</category>
  </item>
</channel>
</rss>
