Touch ID for sudo takes one line, and since Sonoma it survives updates

My take: Apple wrote the line and keeps it safe from updates. On the Mac I work on every day, I see no reason left to type my password for sudo.
What to know
- macOS checks who you are through PAM (pluggable authentication modules): files in
/etc/pam.d/that list, command by command, which proofs it accepts. Since macOS Sonoma (version 14, released on September 26, 2023), Apple's file forsudostarts by including one namedsudo_local, and macOS ships asudo_local.templatewhose first comment says it "survives system update". The Touch ID line is already in it, commented out, as Apple's published source shows. - Copy the template, then delete the
#in front ofauth sufficient pam_tid.so. Sufficient means a fingerprint is enough on its own; when Touch ID fails, the next lines of Apple's file ask for your password as before.sudo -kforgets the last authentication, so your next sudo command shows the prompt. - The limits: pam_tid skips the prompt when you are connected over SSH, notes the README of pam_reattach. Inside tmux or screen, Touch ID is out of reach too, unless you add that module (
brew install pam-reattach) on a line before pam_tid, with its full path on Apple silicon (/opt/homebrew/lib/pam/pam_reattach.so). With the lid closed, the built-in sensor is out of reach and you type your password; Apple's template says nothing about the Apple Watch, which third-party modules such as pam-watchid cover.
sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
sudo nano /etc/pam.d/sudo_local
Spotted on @adjacentnode's reel, in English.
What changes
If you type sudo on your Mac every day, a fingerprint replaces the password, and the setting no longer vanishes with a macOS update, as edits to /etc/pam.d/sudo itself used to. Touch only that one line: a broken PAM file can lock you out of sudo, so keep a second Terminal window with a root shell (sudo -s) open until the test passes.
Source: Apple, “pam.d/sudo_local.template (sudo-106, macOS 14.0)”, September 26, 2023
Drafted with Claude, Anthropic's AI, from my take. Reviewed and owned by me.