../ Software Development
-rw-r--r--aguang1.2 KiB1 min read

Enable Touch ID for sudo on macOS

  • System: macOS Sequoia 15.5

Enable Touch ID for sudo

Since macOS Sonoma 14.0, it is allowed to use Touch ID for sudo with a configuration that persists across software updates using /etc/pam.d/sudo_local.

Update /etc/pam.d/sudo_local

bash
# Enable Touch ID for sudo.
auth  sufficient  pam_tid.so

Enable Touch ID for sudo over tmux, screen or other terminal multiplexers

But macOS’s Touch ID PAM module (pam_tid.so) requires access to the user session context associated with a physical GUI login, which can be lost when using multiplexers. We also need pam_reattach.so to rebinds the PAM process to the correct macOS session.

Install pam-reattach

bash
brew install pam-reattach

Update /etc/pam.d/sudo_local

Make sure you check the location of pam_reattach.so installed. When it is not installed in /usr/lib/pam or /usr/local/lib/pam (e.g., on M1 Macs where Homebrew is installed in /opt/homebrew), you must specify the full path to the module in the PAM service file as shown below:

bash
# Enable Touch ID for sudo over tmux / screen.
auth  optional    /opt/homebrew/lib/pam/pam_reattach.so

COMMAND INTERFACE

↑ ↓ navigate · Enter execute · Esc exit · try “whoami”

Loading filesystem…

:help aguang.xyz

A personal website disguised as an operating system.

Ctrl / Cmd + K
Command palette + full-text search
Tab / Shift + Tab
Move between links and controls
Enter
Open a focused link or search result
↑ / ↓ in search
Navigate search results
In a directory filter
Enter/Done or ↓ focuses a result; Esc clears the filter
Esc
Clear a search or close a window