brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ssh-keygen -t ed25519-sk ties an SSH key to a hardware security key

Security
~/tips/tip-security-ssh-keygen-ed25519-sk

ssh-keygen -t ed25519-sk -C "laptop-key"

Creates an SSH key that needs your hardware security key to be used.

A private key in a file can be copied. With a FIDO security key, part of the key stays in the hardware, and OpenSSH supports that directly.

The key type is ed25519-sk. Plug in the security key and run:

ssh-keygen -t ed25519-sk -C "laptop-key"

The comment is only a label. The files are named like the other key types, for example ~/.ssh/id_ed25519_sk, and the public part goes into authorized_keys as usual. The manual explains how it works: the key consists of a key handle stored in the private key file on disk, and a per-device private key that is unique to each authenticator and cannot be exported from the hardware. The two are combined at authentication time. You can use the key like any other type, as long as the authenticator is attached, and these devices generally want a touch or tap to approve each operation.

Options for it go through -O:

  • -O resident stores the key handle on the authenticator itself, which makes it easier to use on several computers and typically needs a PIN set on the device first
  • -O verify-required asks for user verification for each signature, which for now means the PIN, and not every authenticator supports it
  • -O no-touch-required drops the touch, and the manual notes that sshd refuses such signatures by default unless an authorized_keys option overrides it

A resident key can be downloaded from the device again with ssh-keygen -K, which writes the key files to the current directory.

The caveats come from the same page. Storing both parts of the key on the authenticator, with resident, makes it more likely that an attacker can use a stolen device. And because the per-device private key cannot be exported, a lost or broken key means that private part is gone. Register a second security key, and keep another way into the server until you have tested both.

Further reading: ssh-keygen man page

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link