Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use TouchID for sudo on modern MacBook Pro machines
# curl -sL | bash
# This script is ready to copy-paste in whole, or just the line above (without the leading #)
# Use TouchID for sudo on modern MacBook Pro machines
# This script adds a single line to the top of the PAM configuration for sudo
# See: for more info.
sudo bash -eu <<'EOF'
# A backup file will be created with the pattern /etc/pam.d/.sudo.1
# (where 1 is the number of backups, so that rerunning this doesn't make you lose your original)
bak=$(dirname $file)/.$(basename $file).$(echo $(ls $(dirname $file)/{,.}$(basename $file)* | wc -l))
cp $file $bak
awk -v is_done='pam_tid' -v rule='auth sufficient' '
# $1 is the first field
# !~ means "does not match pattern"
if($1 !~ /^#.*/){
# $0 is the whole line
if(line_number_not_counting_comments==1 && $0 !~ is_done){
print rule
}' > $file < $bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.