Authenticate sudo with TouchID on a MacBook Pro

If you own a Mac equipped with a touch bar and you use the command line and sudo often, you can enable the TouchID of your Mac to authenticate yourself.

Open the terminal app:

sudo vi /etc/pam.d/sudo

Now add the line

auth sufficient pam_tid.so

directly as the first line after the comment.

I looks now 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

The next time you use sudo, you will be prompted to use your fingerprint to authenticate.