Created
September 23, 2022 03:11
-
-
Save leongkui/3bb3af23ed332cb1d616e9dabe3e5fad to your computer and use it in GitHub Desktop.
sudo with touch ID
This file contains hidden or 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
#!/bin/bash | |
# | |
# credit to machupicchubeta/dotfiles/bin/enable_to_sudo_authenticate_with_touch_id.sh | |
set -eu | |
set -o pipefail | |
sudo chmod +w /etc/pam.d/sudo | |
if ! grep -Eq '^auth\s.*\spam_tid\.so$' /etc/pam.d/sudo; then | |
( set -e; set -o pipefail | |
# Add "pam_tid.so" to a first authentication | |
pam_sudo=$(awk 'fixed||!/^auth /{print} !fixed&&/^auth/{print "auth sufficient pam_tid.so";print;fixed=1}' /etc/pam.d/sudo) | |
sudo tee /etc/pam.d/sudo <<<"$pam_sudo" | |
) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment