Skip to content

Instantly share code, notes, and snippets.

@ayr-ton
Last active June 27, 2022 13:21
Show Gist options
  • Save ayr-ton/761c4307eb3177693cb7b0b7122d6f0c to your computer and use it in GitHub Desktop.
Save ayr-ton/761c4307eb3177693cb7b0b7122d6f0c to your computer and use it in GitHub Desktop.
U2F sudo with Yubikey or Ledger Nano

Install for your distribution

MacOS:

brew install pam-u2f

For Arch Linux:

pacman -S pam-u2f

Configure it with your Yubikey or Ledger device:

mkdir -p ~/.config/Yubico/
pamu2fcfg > ~/.config/Yubico/u2f_keys
pamu2fcfg -n >> ~/.config/Yubico/u2f_keys

For MacOS, add on the first line of /etc/pam.d/sudo:

auth       sufficient     /opt/homebrew/Cellar/pam-u2f/1.2.1/lib/pam/pam_u2f.so

For Linux, same first line of /etc/pam.d/sudo, but different content:

auth       sufficient    pam_u2f.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment