Using Touch ID for sudo authentication on a MacBook

Using Touch ID for sudo authentication on a MacBook

I absolutely love unlocking my MacBook Pro with my fingers. I could live without it, of course, but it's really convenient!

The good news is that it's natively available as a PAM module! Meaning Touch ID can be used to authenticate with sudo.

All you need to do is to add this line to /etc/pam.d/sudo:

# sudo: auth account password session
auth sufficient pam_tid.so #<= this line
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

It will make Touch ID the default authentication method but will fallback to others if needed.

If you're using iTerm2, there is a bug on recent version so you need to turn off Preferences > Advanced > Allow sessions to survive logging out and back in.

That's it 🎉

Stanislas
Author
Stanislas
I like building things with code and computers

Comments

3Atom feed
Markdown supported
  1. HLFH

    And you may need to do "chmod u+rw /etc/pam.d/sudo" to edit the previously read-only file, save, quit, and then "chmod u-w /etc/pam.d/sudo"

  2. GT

    Stan thanks for the tip! this is perfect.

  3. Joseph

    Hi, as of osx 12.2.1, is this still valid ? Indeed after adding this line, I now have the os password prompt which is displayed when I sudo something.