This guide sets up hardware-backed SSH keys using a YubiKey.
Your private key stays inside the YubiKey. You share only the public key with sysadmins.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"brew install yubikey-manager libfido2 opensshVerify YubiKey is detected:
ykman listYou should see your YubiKey listed.
macOS ships OpenSSH without full FIDO2 support. We must use Homebrew’s OpenSSH.
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zprofile
source ~/.zshrc
source ~/.zprofileVerify:
which ssh
which ssh-keygenExpected:
/opt/homebrew/bin/ssh
/opt/homebrew/bin/ssh-keygen
nano ~/.ssh/configAdd:
Host *
SecurityKeyProvider /opt/homebrew/opt/libfido2/lib/libfido2.dylib
Verify OpenSSH sees the provider:
ssh -Q security-key-providersExpected output:
/opt/homebrew/opt/libfido2/lib/libfido2.dylib
Unplug and re-insert your YubiKey, then:
ssh-keygen -t ed25519-sk -O verify-required -C "your.email@noaa.gov" -f ~/.ssh/id_ed25519_yubikeyWhen prompted:
- Touch the YubiKey
- Set a PIN (recommended)
- Optional passphrase
This creates:
~/.ssh/id_ed25519_yubikey
~/.ssh/id_ed25519_yubikey.pub
ssh-add ~/.ssh/id_ed25519_yubikey
ssh-add -LYou should see:
sk-ssh-ed25519@openssh.com AAAA...
cat ~/.ssh/id_ed25519_yubikey.pubSend that line to your sysadmin to add to:
~/.ssh/authorized_keys
nano ~/.ssh/configAdd:
Host myserver
HostName myserver.company.com
User youruser
IdentityFile ~/.ssh/id_ed25519_yubikey
IdentitiesOnly yes
Now:
ssh myserverTouch YubiKey when prompted.
ssh-keygen -t ed25519-sk -O verify-required -C "your.email@company.com" -f ~/.ssh/id_ed25519_yubikeyykman fido access change-pinRegister a second YubiKey:
ssh-keygen -t ed25519-sk -C "your.email@company.com-backup" -f ~/.ssh/id_ed25519_yubikey_backupSend both .pub keys to sysadmin.
| Symptom | Fix |
|---|---|
| Unsupported query "security-key-providers" | You’re using Apple OpenSSH. Fix PATH to Homebrew OpenSSH |
| No FIDO SecurityKeyProvider specified | libfido2 not installed or wrong path in config |
| No touch prompt | Wrong key selected. Use IdentitiesOnly yes |
| Permission denied | Public key not in authorized_keys |
| YubiKey not detected | Run ykman list |
which ssh
ssh -V
ssh -Q security-key-providers
ykman list- Private key never leaves YubiKey
- Physical presence required
- Phishing-resistant
- No SSH agent forwarding risk
- Works with standard OpenSSH servers