This is just a note to my future self - no assurances it will work for you!
This fix isn't permanent and will be overwritten by the system arbitrarily, hence why I wrote down the steps and script that worked for me here so I can easily set it again. The previous sentence was true until macOS Sonoma (14) was released, which now allows TouchID for sudo to persist across updates and restarts. The script will automatically detect if you are on Sonoma or later and apply that permanent change instead of the earlier, non-permanent fix.
Copy + run the line below.
curl -fsSL https://gist.githubusercontent.com/uncenter/604233698c41f1c54079760b93fbabf0/raw/x.sh | sh
- Open
/etc/pam.d/sudo
in your editor with sudo. You should see something similar to the following examples:
# sudo: auth account password session
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
# sudo: auth account password session
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
- Add an additional line,
auth sufficient pam_tid.so
, to the top:
# sudo: auth account password session
+ auth sufficient pam_tid.so
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
If you are unable to save the file in your editor, either try the next set of instructions or if you are using a visual editor like Visual Studio Code, try the above instructions again but in a command line editor such as vi
, vim
, nvim
, helix
, etc.
- In your preferred terminal, copy and paste the contents of
/etc/pam.d/sudo
(cat /etc/pam.d/sudo
) into a new temporary file:cat /etc/pam.d/sudo >> temp.txt
). temp.txt
should now look (cat temp.txt
) similar to one of the following:
# sudo: auth account password session
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
# sudo: auth account password session
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
- Edit
temp.txt
and add an additional line (auth sufficient pam_tid.so
) to the top so it now looks like this:
# sudo: auth account password session
+ auth sufficient pam_tid.so
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
- To make our changes have an effect, we need to replace the old file with our new one:
sudo cp temp.txt /etc/pam.d/sudo