Securing SSH with FIDO2 (2024)

Background and Scope

SSH (Secure Shell) is vital for secure remote connections over unsecured networks. Choosing a robust authentication mechanism is crucial. FIDO2 security keys introduce a strong, user-friendly option for SSH authentication, offering multi-factor authentication (MFA) via hardware tokens.

This guide provides instructions for integrating FIDO2 with SSH, focusing on resident keys (also known as passkeys). It covers client and server configuration, key generation, and usage across Linux, macOS, and Windows platforms, ensuring a secure and streamlined SSH authentication experience.

Prerequisites

  • OpenSSH 8.3 or newer

  • FIDO2 security key

  • YubiKey Manager (for setting the FIDO2 PIN)

About Using FIDO2 Security Keys for SSH

Why use FIDO2?

  • Enhanced Security: The private key is securely generated and stored on the YubiKey and cannot be exported.

  • User Presence and Verification: Offers user verification via PIN and user presence through physical touch.

  • User Preference or Policy: Extends existing FIDO2 usage when a security key is also being used for web app and desktop sign in.

How FIDO2 works with SSH:

  • Credential Files:

    • Public key file (.pub) shared with the remote host.

    • Private key file in this case doesn’t actually contain the private key. Instead in contains a key handle (Credential ID) which references the private key on the security key.

Cryptographic Algorithm Options:

  • ed25519-sk

    • Recommended for better security and performance. Requires firmware 5.2.3 or higher.

  • ecdsa-sk

SSH Key Generation Options:

  • resident: Store the key handle on the FIDO2 authenticator itself. A PIN should be set on the authenticator prior to generation.

  • verify-required: Indicates the private key should require user verification for each signature.

Configuring the SSH Client

Linux

  1. Insert the security key.

  2. Open a terminal.

  3. Generate the ssh credential files:

    ssh-keygen -t ed25519-sk -O resident -O verify-required -C "Your Comment"
  4. Enter the PIN and touch the key when prompted.

  5. Save the files (id_ed25519_sk and id_ed25519_sk.pub) in the ~/.ssh directory.

macOS

  1. Install OpenSSH via Homebrew:

    brew install opensshsource ~/.profile
  2. Insert the security key.

  3. Open a terminal and generate the key:

    sudo ssh-keygen -t ed25519-sk -O resident -O verify-required -C "Your Comment"
  4. Enter the PIN and touch the key when prompted.

  5. Save the files in the ~/.ssh directory.

Windows 10/11

  1. Verify OpenSSH is installed. Get started with OpenSSH for Windows.

  2. Insert the security key.

  3. Open PowerShell (as administrator) and generate the key:

    ssh-keygen -t ed25519-sk -O resident -O verify-required -C "Your Comment"
  4. Enter the PIN and touch the key when prompted.

  5. Save the files in the ~/.ssh directory.

Configuring Additional SSH Clients

To use the security key on a new system:

  1. Insert the key and open a terminal.

  2. Change to the SSH directory:

    cd ~/.ssh
  3. Regenerate key files from the security key:

    ssh-keygen -K

Configuring the SSH Server

Update the SSH server to enforce user verification.

  1. Edit sshd_config:

    1. Open the file (usually at /etc/ssh/sshd_config).

    2. Add:

      PubkeyAuthOptions verify-required

.Save and exit.

  1. Restart SSH:

    sudo systemctl restart sshd

Example sshd_config to disable passwords altogether (optional, enhanced security):

# Support public key cryptography (includes FIDO2)PubkeyAuthentication yes# Enforce User VerificationPubkeyAuthOptions verify-required# Public keys locationAuthorizedKeysFile .ssh/authorized_keys# Allow root only with MFAPermitRootLogin prohibit-password# Disable password authenticationPasswordAuthentication noPermitEmptyPasswords no

Sharing the Public Key

Using ssh-copy-id

  1. Open a terminal and use:

    ssh-copy-id -i ~/.ssh/id_ed25519_sk.pub user@host

Manual Editing

  1. Copy the public key content.

  2. Log in to the server.

  3. Open the authorized_keys file:

    nano ~/.ssh/authorized_keys
  4. Paste the public key and save.

Using SSSD (Optional)

  • For centralized management, store public keys in LDAP (for instance Active Directory) using SSSD.

Using Multiple SSH Credentials

To generate multiple credentials on the same security key:

ssh-keygen -t ed25519-sk -O resident -O application=ssh:Description -C "Comment"

Replace Description with a unique identifier for each credential.

SSH to remote host using FIDO2

  1. . Open a terminal and use:

  2. Enter the PIN and touch the key when prompted.

Troubleshooting

Password Prompts Instead of YubiKey:

  • Restart or log out/in.

  • Verify OpenSSH version (ssh -V).

  • Check system logs for errors:

    • Ubuntu/Debian:

      tail /var/log/syslog | grep sshd
    • Fedora:

      journalctl -r /usr/sbin/sshd
  • Run SSH in debug mode:

    ssh -vvv user@host

Permission Issues:

  • Ensure correct file permissions:

    chmod 600 ~/.ssh/id_ed25519_sk

Unsure which security key holds the credential

Regenerate key files from the security key and compare public keys.

  1. Open a terminal and use:

    ssh-keygen -K
  2. Enter the PIN and touch the key when prompted.

  3. Compare the newly generated public key to the public key in question

Securing SSH with FIDO2 (2024)
Top Articles
How to Trade Cryptocurrency: A Beginners Guide • Benzinga
United States Stock Market Index - Quote - Chart - Historical Data
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Mr. See Jast

Last Updated:

Views: 5431

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Mr. See Jast

Birthday: 1999-07-30

Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

Phone: +5023589614038

Job: Chief Executive

Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.