Skip to content
SecureKeys

Learn

SSH logins and signed Git commits with a security key

Use a FIDO2 security key for SSH (ed25519-sk and ecdsa-sk) and to sign Git commits, so a stolen laptop or leaked key file is not enough to reach your servers or impersonate you.

SecureKeys Engineering ·

An ordinary SSH private key is a file. Malware or a stolen backup can copy it. With a FIDO2 security key, the private key stays on the hardware: each login or signature needs the key plugged in and touched, and optionally its PIN.

What you need

  • A FIDO2 security key. For ed25519-sk on a YubiKey, Yubico says firmware 5.2.3 or newer; older keys can use ecdsa-sk.
  • OpenSSH 8.2 or newer (8.3 to download resident keys with ssh-keygen -K, 8.4 for verify-required).
  • For commit signing: Git 2.34 or newer.

Check with ssh -V and git --version.

1. Create an SSH key on the security key

ssh-keygen -t ed25519-sk -O resident -O verify-required -C "you@example.com"
  • -t ed25519-sk creates a key whose private part lives on the security key (use ecdsa-sk if Ed25519 is not supported).
  • -O resident stores it on the key, so you can recover it on a new computer with ssh-keygen -K.
  • -O verify-required asks for the key’s PIN on every use, not just a touch.

The files written to ~/.ssh are a handle and the public key. The handle is useless without the physical key.

2. Use it for server logins

Add the .pub file to ~/.ssh/authorized_keys on the server, or to your Git host. GitHub and GitLab accept security-key SSH keys. Check self-hosted tools before relying on them: Atlassian documents that FIDO2 SSH keys do not work with Bitbucket Data Center.

On servers you control, you can require PIN verification for every security-key login with PubkeyAuthOptions verify-required in sshd_config.

3. Sign Git commits with the same key

git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519_sk.pub
git config --global commit.gpgsign true

Point user.signingkey at the .pub file. If you paste the key text instead, Git needs a key:: prefix.

Then add the same public key to GitHub (Settings → SSH and GPG keys → New SSH key, type Signing Key) or to GitLab. Signed commits show as Verified.

4. Register a backup key

Generate a second SSH key on a second security key, add both public keys everywhere, and keep the spare somewhere safe. See what to do if you lose a key.

Odoo teams

If you deploy Odoo from Git (including Odoo.sh), this protects the path from a developer’s laptop to production. Pair it with server hardening and security keys for Odoo sign-in.

References

  1. Yubico: Securing SSH authentication with FIDO2 security keys
  2. Yubico: GitHub now supports SSH security keys
  3. GitHub Docs: Telling Git about your signing key
  4. GitLab Docs: Sign commits with SSH keys
  5. Atlassian: FIDO2 based SSH keys don't work in Bitbucket Data Center
  6. Ubuntu Server docs: Two-factor authentication with U2F/FIDO

Plan your move beyond passwords

Talk to our engineers about phishing-resistant authentication for your organisation. We reply within one business day.