DEV Community

Cover image for Use Touch ID for sudo in macOS Terminal
Pierre Janineh
Pierre Janineh

Posted on

Use Touch ID for sudo in macOS Terminal

If you're a nerd like me and use long, complex passwords (because security ✨), typing them over and over in Terminal can be a pain. Good news: you can enable Touch ID for sudo on macOS and never type your password again when using the command line.

TouchID prompt instead of password for sudo

✅ Why Use Touch ID for sudo?

By default, every time you run a sudo command in macOS Terminal, you’re prompted for your password. With a quick tweak, you can authenticate with your fingerprint instead — just like unlocking your Mac.


🔧 How to Enable Touch ID for sudo

1. Open Terminal and edit the sudo PAM config

sudo nano /etc/pam.d/sudo
Enter fullscreen mode Exit fullscreen mode

Enter your password one last time the old-fashioned way.

2. Add the following line at the very top of the file:

auth    sufficient    pam_tid.so
Enter fullscreen mode Exit fullscreen mode

This tells macOS to allow Touch ID as an authentication method for sudo.

3. Save and exit:

• Press Control + X to exit
• Press Y to save
• Press Enter to confirm and exit

4. Try it out

Run any sudo command, like:

sudo ls /var/root
Enter fullscreen mode Exit fullscreen mode

You should see a Touch ID prompt instead of being asked for your password.


🛡️ Notes

• This only works on Macs with Touch ID (Apple Silicon or Intel with T2 chip).
• If Touch ID isn’t available, it will fall back to your password.
• Be careful editing system config files — a typo can break sudo access.


🙌 Enjoy a faster, more secure terminal experience

This small change can save you keystrokes daily and make your command line life just a little more delightful.

Have questions or improvements? Drop a comment below!

Top comments (0)