Last active
June 2, 2023 18:29
-
-
Save gabrielfeo/81eb9aea3db3abeb505c9d1ad795a7b2 to your computer and use it in GitHub Desktop.
Add touch ID as valid authentication for sudo on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '!/^#/ && !p { print "auth sufficient pam_tid.so"; p=1 }1' /etc/pam.d/sudo \ | |
| tee ./temp-pamd \ | |
&& read \ | |
&& sudo mv ./temp-pamd /etc/pam.d/sudo | |
&& rm ./temp-pamd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simply copy it and run in a shell. It re-writes the
/etc/pam.d/sudo
file using awk, but prints the new content and waits for user to review it. If you press enter, it will actually change/etc/pam.d/sudo
with the new content, or press Ctrl+C to make it exit before changing.Awk explanation:
!/^#/
: Matches lines that do not start with #.!p
: Ensures that the line has not been previously printed.print "auth sufficient pam_tid.so"
: Prints the required line before any non-comment line.p=1
: This is set after the first non-comment line is encountered, ensuring the line is only printed once.1
: Is AWK shorthand for print the line. This happens for every line, ensuring all lines (modified and not) are printed.