Intro

This is about why and how to setup hardware security tokens on Linux/MacOS. I only use hardware security tokens for all SSH, encryption, and almost all file signing to eliminate a vast swath of attack vectors. Notably, it is not about the many other, probably more important, things worth protecting with this level of security (bank account numbers, email auth, etc).

See: https://xkcd.com/1200/ and a future blog post about my thoughts on that.

My background

Why should you trust me? I spent a few years working as a defensive cybersecurity team lead and analyst for the US Army Cyber Protection Brigade - the Army’s advanced defensive cybersecurity arm. I’ve also worked at some agencies I won’t name working on sensitive projects that involve knowing security really well. But, I’m not an expert and I get things wrong. As always, use your executive judgment and decide for yourself.

Threat

Security only makes sense as protection against specific threats. Bank vaults aren’t built to withstand nuclear blasts and your security profile shouldn’t be defending against the National Security Agency (NSA).

My setup is about defending against

  • Rogue GenAI agents.

  • Phishing attacks.

  • Insider / man-in-the-middle threats at my Internet Service Provider (ISP), or other infrastructure providers.

  • Adware.

  • the run-of-the-mill viruses, trojans, etc.

What I am not defending against

  • Nation State-funded cybersecurity analysts.

    • It is VERY difficult (as in, impossible) to protect yourself from a research lab worth of people with unlimited funding and time.

    • Also; https://xkcd.com/538.

  • Highly capable quantum computers (with 100’s to 1000’s of usable qubits).

    • This threat is only theoretical at this point, but probably valid. However, there is not broad support for these algorithms yet and the theoretical benefits are not worth the very expensive up-front cost (time, hardware, support, etc).

Principles

Putting software keys into hardware security devices adds a significant amount of security with a modest cost to convenience and reasonable price. Some examples are: YubiKey, Apple Secure Enclave, Trusted Platform Module (TPM), or similar.

Backups are only as good as the last time they’ve been restored, so you should use multiple devices often.

Cybersecurity is only as good as the processes and people involved. No encryption or software can stop the recipient from leaking your data.

Lastly, follow best practices.[1]

CIA triad

All cybersecurity practices revolve around protecting the so-called "CIA" triad:

  • Confidentiality: Only authorized parties can read the information.

  • Integrity: The data is unaltered, the sender is who they say they are.

  • Availability: The data/system is available.

    • This also includes "convenience" because things that are simple and easy yet time-consuming (such as going to the security deposit box) can also be their own sort of barrier. As is shown time and time again,[2] convenience matters.

Encryption helps with confidentiality. Modern encryption schemes and tools practically guarantee the confidentiality of the data they encrypt. However, there are so many other things to consider. Encrypting the body of an email doesn’t stop anyone from seeing the metadata (who is sending, who is receiving), for example. Please don’t use email for encrypted communication.

Signing helps with integrity. Modern cryptographic signing assure you that the signed file comes from who the signature claims it is from. This is an important distinction, because anyone could cryptographically sign a file and say that they are "Holland Gibson", and the signature would be cryptographically valid. You must use another process to validate that the signature is from the person or organization you think it is from. This is why Transport Layer Security (TLS, basically https://) certificates are signed by higher and higher authorities that do real due diligence to confirm that each subordinate certificate is from the actual person claiming to be creating that certificate. This is also why I use keyoxide (see my about page), because it is highly unlikely that an impersonator could gain control of my GitHub account, Codeberg account, and website at the same time.

Hardware tokens must be easy to use in order to meet availability requirements. You must also have backups, because keys get lost, break, get stolen, or worse and a loss of a hardware key cannot then prevent you from using all your services.

Lastly, cybersecurity is asymmetrical. Defenders (i.e. you) must defend against every threat, while attackers must only find a single vector that is unprotected.

Complexity is the enemy here. The simpler your setup can be, the more likely it is to be done correctly and for you to notice when things are awry.

This is a collaborative process. You can have the best security in the world, but if your spouse has access to your accounts, they can just hack them instead.

Every additional backup or alternative solution reduces your security posture. Your password complexity is irrelevant if an attacker can just claim to be you on the phone and have an agent reset your password, or if the attacker can just the "forgot my password" feature and intercept the response.[3]

See the MITRE "attack" framework for a categorical organization of every kind of threat.

In practice

Encryption

Age actually explains it pretty well:

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

— age homepage

Age is also audited, and easy to utilize.

Signing

There are two good options I’d recommend:

Both of these are widely supported, audited signature tools. OpenSSH is more common than minisign, so that is probably preferred.

Signing things as an enterprise or organization rather than an individual is a different question and has different answers. Cosign/Sigstore is a good starting place though.

How to set up

Hardware

This is what I used in this setup

  • YubiKey 5c NFC

    • age and KeePassXC both require the additional security features not available on the cheaper fido2-only "security key". But if all you need is SSH and webauthn, and fido, then the security key is worth the 50% cheaper price.

  • Macbook M1 Pro, although any mac with the arm (M1, M2, etc) chipset and a Touch-ID button (external keyboard or integrated) will work.

I have tried using an OnlyKey but it simply does not have the broad support and convenience to be at the same tier of YubiKey.

MacOS

To read how to setup using the MacOS secure enclave for ssh and age, read my MacOS SE setup post.

YubiKey

To read how to setup using the YubiKey for ssh and age, read my YubiKey setup post.

TPM

There are methods to setup most of these using Trusted Platform Modules (TPMs), but I haven’t had the time to investigate those yet.

These look like solid posts to follow:


1. See: https://words.filippo.io/right-answers/ for the latest and pretty solid set of these.
2. One of the main priciples of Nist 800-53 is that things that are annoying end up reducing security because people create workarounds, such as passwords on post-it notes.
3. These are very real threats and result in some fairly high profile successful attacks every year.