2019/10/26

Use administrator privileges with Touch ID from ShellScript / Terminal


From Terminal (sudo)

Add line auth sufficient pam_tid.so to /etc/pam.d/sudo
$ cat /etc/pam.d/sudo
auth       sufficient     pam_tid.so
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so

ex.

$ sudo su

From ShellScript

Use osascript like followings..
osascript -e 'do shell script "Command or ShellScript" with administrator privileges'

ex.(using with heredocument)

$ osascript <<EOD
do shell script "whoami" with administrator privileges
EOD

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。