Generate PKCS#12 certificates for YubiKey authentication on macOS. These scripts create the required certificates for passwordless login and keychain access.
Result: Insert your YubiKey, enter your PIN once, and access both macOS and your keychain without typing passwords.
-
Generate certificates:
chmod +x *.zsh ./secp.gen.zsh 9a your@email.com # For login (slot 9a) ./rsa.gen.zsh 9d your@email.com # For keychain (slot 9d)
-
Load onto YubiKey: Import the generated
.pfxfiles using YubiKey Authenticator -
Pair with macOS: Use
sc_auth pairto enable authentication
- Purpose: macOS login authentication
- Algorithm: ECC P384 (FIPS 140 compatible)
- Purpose: Unlock macOS keychain
- Algorithm: RSA2048 (required for keychain compatibility)
Both certificates are required for complete passwordless authentication.
Each script requires a prefix (slot number) and Common Name. Use an email or domain for the Common Name:
./secp.gen.zsh 9a john@doe.net # Creates ECC P384 for authentication
./rsa.gen.zsh 9d john@doe.net # Creates RSA2048 for keychainOutput files:
./john@doe.net/9a/9a.secp384r.pfx # Load into slot 9a (Authentication)
./john@doe.net/9d/9d.rsa.pfx # Load into slot 9d (Key Management)
Note: The scripts will prompt for a PFX password - store this in your password manager.
- Install YubiKey Authenticator
- Set a PIN if not already configured
- Import certificates using the "Import" button:
- Authentication (9a): Import the
9a.secp384r.pfxfile - Key Management (9d): Import the
9d.rsa.pfxfile
- Authentication (9a): Import the
Prerequisites: YubiKey must have a PIN set and both certificates loaded.
-
Find your identity:
sc_auth identities
-
Pair with your user:
sc_auth pair -u $USER -h <identity-hash>
-
Verify pairing:
sc_auth list -u $USER
Your YubiKey is now ready for passwordless authentication. You can test by logging out and back in using only your YubiKey PIN.
See ./LONGFORM.md