OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Check the Authenticator
        • Create a Non-Resident Credential
        • Install and Test the Public Key
        • Require User Verification
        • Create a Resident Credential
        • Enroll a Backup Credential
        • Operational Limits

        Use FIDO Security Keys with OpenSSH

        Synopsis #

        ssh-keygen(1) can create FIDO authenticator-backed SSH keys. The authenticator retains private key material and normally requires a physical touch for each signature. OpenSSH supports ecdsa-sk and ed25519-sk key types.

        A non-resident credential stores a key handle in the local private-key file. Both that file and the authenticator are required. A resident credential stores the key handle on a FIDO2 authenticator and can be recovered to another client, but a stolen authenticator may expose more usable credential material.

        Maintain a separate tested recovery credential. A hardware token can be lost, damaged, reset, or unavailable.

        Check the Authenticator #

        Attach one authenticator to the OpenBSD client. OpenSSH uses internal USB HID support by default and can select a fido(4) device without an external provider.

        Confirm that the kernel attached the device:

        dmesg | grep '^fido'
        

        Device support and token capabilities vary. If ed25519-sk enrollment is rejected, try ecdsa-sk, which is supported by a wider range of authenticators.

        Create a Non-Resident Credential #

        Generate a credential on the client:

        ssh-keygen -t ed25519-sk -f ~/.ssh/id_ed25519_sk
        

        Touch the authenticator when prompted. Protect the local key-handle file with a passphrase when practical.

        Inspect the public-key fingerprint:

        ssh-keygen -lf ~/.ssh/id_ed25519_sk.pub
        

        The file without .pub is not a conventional exportable private key, but it remains sensitive because it contains the handle needed to use the authenticator.

        Install and Test the Public Key #

        Append the .pub file to the server account’s ~/.ssh/authorized_keys using an existing authenticated connection:

        ssh admin@server.example.com 'umask 077; mkdir -p .ssh; cat >> .ssh/authorized_keys' < ~/.ssh/id_ed25519_sk.pub
        

        Test the security key explicitly:

        ssh -o IdentitiesOnly=yes -o PreferredAuthentications=publickey \
            -o PasswordAuthentication=no -o KbdInteractiveAuthentication=no \
            -i ~/.ssh/id_ed25519_sk admin@server.example.com
        

        OpenSSH should request a touch when it signs the authentication challenge. Keep the existing recovery session open until this succeeds.

        Require User Verification #

        Some FIDO2 authenticators can require a PIN for user verification when producing each signature. Generate such a key with:

        ssh-keygen -t ed25519-sk -O verify-required -f ~/.ssh/id_ed25519_sk_verify
        

        To enforce verification at the server, prefix this key’s authorized_keys entry with verify-required, as documented in sshd(8) . A client generation option alone does not enforce server policy.

        Not every authenticator supports this option. Test the actual client, token, and server combination before depending on it.

        Create a Resident Credential #

        Set a PIN on the authenticator using its supported management procedure before creating a resident key. Then enroll the resident credential:

        ssh-keygen -t ed25519-sk -O resident -O verify-required -f ~/.ssh/id_ed25519_sk_resident
        

        To recover resident credentials on another trusted OpenSSH client, create an empty private directory and run ssh-keygen -K there:

        mkdir -m 700 ~/recovered-fido-keys
          # Create a protected destination
        cd ~/recovered-fido-keys
          # Avoid overwriting existing key files
        ssh-keygen -K
          # Download resident key handles from the touched authenticator
        

        Inspect the recovered public keys and fingerprints before use. Do not assume the generated filenames identify the correct account.

        Enroll a Backup Credential #

        Repeat enrollment with a second authenticator and add its public key as a separate authorized_keys line. Test the backup token from a new client session.

        Store the backup token separately from the primary token. Record which public-key fingerprint belongs to each device. Remove the corresponding authorized_keys line immediately after a token is lost or retired.

        Operational Limits #

        • Touch confirms user presence, not the identity of the person touching the device.
        • verify-required adds user verification only when the authenticator supports it.
        • A non-resident token alone is insufficient without its local key-handle file.
        • A resident credential improves portability but increases the consequences of token theft.
        • Disabling all other credentials before the backup token is tested can cause lockout.

        See Configure Secure Remote Access with OpenSSH for server policy, PF exposure, logging, and recovery.

        Report a bug
        • Synopsis
        • Check the Authenticator
        • Create a Non-Resident Credential
        • Install and Test the Public Key
        • Require User Verification
        • Create a Resident Credential
        • Enroll a Backup Credential
        • Operational Limits