Using TouchID with Sudo in Terminal or iTerm

Published November 24th, 2020
2 minute read
This was written over two years ago, so some information might be outdated. Frameworks and best practices change. The web moves fast! You may need to adjust a few things if you follow this article word for word.

Now that I've got a mac with TouchID, I rarely use my password. It's incredible how convenient that little button is. One place I found myself still typing my password was running sudo commands in the terminal.

Here's how you can use TouchID with the terminal too!

Enabling TouchID with Sudo

First, open the /etc/pam.d/sudo in an editor with admin permissions. I had to use sudo to do this with the following command:

sudo code /etc/pam.d/sudo

Add auth sufficient to the file, here's what mine looks like now:
(I only added the line with on it.)

# sudo: auth account password session
auth       sufficient
auth       sufficient
auth       required
account    required
password   required
session    required

iTerm Support

iTerm has an advanced option that you also need to set for this to work properly. Go to
Preferences ⇒ Advanced ⇒ Allow sessions to survive after logging out and back in

Change this setting to No.
Allow Sessions to survive

Restart iTerm and try it out!

TouchID Sudo with iTerm

Enjoy this article? Follow me on Twitter for more tips, articles and links.

Join the Newsletter ❤️

A most excellent monthly newsletter with code & design tips, curated links and more!
Don't worry, I'll never send you spam. Unsubscribe at any time.