如何在终端上使用 MacOS 的 Touch ID

2025-06-05

如何在终端上使用 MacOS 的 Touch ID

我知道……用指纹扫描仪就再也不用回来了。不用写密码、PIN 码或图案。但在终端上,当我们使用魔法词时,sudo它会要求你输入密码……真恶心!!!

恶心

别担心。这个问题可以轻松解决,因为macOS Sonoma现在支持为 sudo 启用 Touch ID:



sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
sudo nano /etc/pam.d/sudo_local


Enter fullscreen mode Exit fullscreen mode

#通过从行首删除来取消注释文件的最后一行。



# sudo_local: local config file which survives system update and is included for sudo
# uncomment following line to enable Touch ID for sudo
auth       sufficient     pam_tid.so


Enter fullscreen mode Exit fullscreen mode

保存更改ctrl+x并覆盖文件。

额外的

在默认终端上可以顺利运行,但在iTerm2上需要额外配置。转到Prefs -> Advanced -> Allow sessions to survive logging out and back in并将值设置为no

轻松简单的日语

重新启动并享受它。


好了,各位!祝您
编程愉快🖖

啤酒

文章来源:https://dev.to/equiman/how-to-use-macos-s-touch-id-on-terminal-5fhg
PREV
iTerm2 + Oh My Zsh! + Powerlevel10K 是极客的最佳终端组合!
NEXT
您的代码听起来怎么样?