Skip to content

Touch ID for sudo (collar)

collar is the small-but-mighty auth room. It enables Touch ID for sudo so privileged commands take a fingerprint instead of a typed password — and, crucially, it makes that work inside a terminal multiplexer like zellij or tmux, where stock Touch-ID-for-sudo silently fails.

collar configures two PAM settings for sudo, and installs one sudoers rule:

security.pam.services.sudo_local.touchIdAuth = true; # fingerprint for sudo
security.pam.services.sudo_local.reattach = true; # make it work in tmux/zellij
  • touchIdAuth adds the Touch ID PAM module to sudo.
  • reattach pulls in pam_reattach, which reattaches the sudo process to your GUI login session.
  • /etc/sudoers.d/darwin-rebuild exempts one command from authentication entirely — see below.

Activating a build is the privileged thing this rice does constantly, and a prompt per rebuild buys nothing: you already authenticated to build it. So collar grants that one command a pass:

<you> ALL=(ALL) NOPASSWD: /run/current-system/sw/bin/darwin-rebuild

haus rebuild and bench try switch both route through that exact path, so rebuilds run straight through. Nothing else is exempt.

Without pam_reattach, running sudo inside zellij or tmux detaches from the Aqua GUI session, so the Touch ID prompt has nowhere to appear — it just beachballs. With it, the prompt reattaches to your GUI session and the sensor lights up as expected. If you cancel, it falls back to a typed password.

collar deliberately stays out of key management. YubiKey and GPG are kept out of Nix: key material, smartcard setup, and pinentry live outside the rice, handled by gpg-agent + pinentry-mac at runtime. This keeps secrets off the Nix store and lets you manage hardware keys the normal way.

Commit signing itself is wired up in hearth from your nebelhaus.git.signingKey — collar only handles the sudo authentication path.

collar has no options of its own — it’s on as part of the rice. If you ever want to opt out, remove or override the two PAM settings (and the sudoers rule, if the passwordless rebuild isn’t to your taste) in your host file. For most people it just works from the first switch, and typing your password to sudo becomes a memory.