LockerGnomeTech news and nostalgia for today's technology professionals
Subscribe

Search

Software

Delete One # and Your Mac's Touch ID Answers sudo

A developer tired of typing a password whenever their agents needed admin rights also found why a docked Mac may stop offering the fingerprint.

Chris, glasses catching a cool glow, presses his index fingertip onto a large glowing fingerprint whorl floating in front of a dark command-line window as a row of password dots crumbles away.
Illustration: LockerGnome

The developer behind modulovalue got tired of typing a password every time their agents ran sudo, the command that borrows administrator rights. So they handed the job to a fingertip. “Now a small prompt shows up.”

The trick lives in PAM, the pluggable authentication modules macOS inherited from Unix. When sudo wants to know you’re you, PAM does the asking. Apple already ships a module called pam_tid.so that sends the question to the fingerprint sensor.

Apple also supplies a template with the right line written out and then commented out (so close, Apple). Copy it, then open the copy:

sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
sudo nano /etc/pam.d/sudo_local

Remove the # in front of this line and save:

auth sufficient pam_tid.so

Open a new terminal and run sudo -v to try it. The word sufficient is doing the heavy lifting: a matching fingerprint is enough by itself. Cancel the prompt and you get the old password question. According to the write-up, that fallback means “you can’t lock yourself out with this.”

The file matters as much as the line. Since macOS Sonoma, sudo_local has been the place for local changes that survive system updates. Edit the main /etc/pam.d/sudo file instead and an update will wipe your work, giving your finger an unplanned vacation.

Then there’s the dock. macOS stops offering Touch ID in these prompts while anything is capturing the screen. Screen sharing and screen recording count. So does the author’s DisplayLink dock, which captures the screen all the time. You buy a dock for more screen, and the fingerprint prompt pays the cover charge.

Their fix was to have an agent write a small replacement PAM module. It asks for the fingerprint through Apple’s LocalAuthentication API directly, which keeps working during screen capture. Because it draws its own prompt, it can also say who is asking and show the full command.

The source, install steps and notes on tracking down the capture problem sit in a macos-touchid-sudo skill in the author’s skills repository. They report using the module for about two months, “every day since without any issues,” and it works just as well on their other two MacBooks.

Tmux users have one more hoop. A commenter, BaziBuilds, pointed out that the Touch ID prompt won’t appear inside tmux unless you also install pam-reattach. Your terminal multiplexer, it turns out, needs help multiplying your thumbs.

Prompt fatigue is the likely next headache. Tap approve often enough and the finger starts working ahead of the brain. The write-up’s addendum passes along a tip from ryan-duve: use sudo visudo to let a specific user run specific commands silently, and save Touch ID for everything else.

The author attaches a big warning. Their example allows gdb, which can start a shell or attach to any process, so allowing it without a password is “effectively the same as giving out root.” A short allow list can still be a very long leash.

A reasonable bet: as more people let agents drive terminals, the useful approval box will be the one that says exactly what it’s approving. A fingerprint proves who touched the sensor. It helps to know what they just touched it for.

Hardware has its say too. The author relays a report from a1b3c3d7, who has used fingerprint approval for sudo for a few months: a slow reader makes it miserable. Nobody wants a shortcut with a loading time.

Read first, then lift a finger.

More Software

Every Software story →