Run script as root upon specific account login without interaction

tnielsen
Valued Contributor

I'd like to run scripts when a specific user logs into any computer. Those scripts need to operate with sudo creds. Is this possible without entering a password?

Actually, now that I think of it I could create a launch daemon in /Library. Then adjust the script to check if the username matches (if statement) then run an elevated command accordingly. Duh, that'll work.

thanks guys!

1 REPLY 1

chris_hansen
Contributor

Or a Policy.

Policy triggered at Login,
Under Files and Processes add your command to be executed as root in the Execute command section.
Scope it to the computers you want, then under Limitations scope to the username.

Test, test, test, of course. It is root.

The advantage could be you can disable a policy from the console.