I want to create a script to automate the installation of brew on new workstations without entering password. In my /etc/sudoers I added the path to my file

dsi ALL = (ALL) ALL
dsi ALL = (root) NOPASSWD: /Users/dsi/Desktop/Hello/script.sh

But I still have to write the password if I execute the script with a simple ./script.sh. If I execute the script with sudo ./script.sh I get the error Don't run this as root!



yes '' | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew cask install vlc

I find this solution but I don't like because I must write the password in clear

  • what's the back story here? Normally I install brew once - the only root / enhanced permissions needed is to set up the permissions and directory so that a root / sudo is never needed again. I wonder if there's a better, larger problem to solve... – bmike Oct 2 at 13:39
  • The problem is that I don't want to type the password every time I install homebrew on new computers – The33Coder Oct 2 at 13:42
  • 2
    Normally brew doesn't require to run as sudo - why do you need it ?? – Rene Larsen Oct 2 at 13:45
  • If I run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" the terminal ask me for password – The33Coder Oct 2 at 14:03
  • Are you running the installation as an admin user? Also, if you need to modify the sudoers file on each machine I don't see the benefit somehow. – nohillside Oct 2 at 14:24

You must log in to answer this question.

Browse other questions tagged .