You could use
sudo networksetup -setautoproxystate Wi-Fi off
and then configure sudoers(5)
to allow that exact command (or any networksetup
invocation (or any command whatsoever)) without a password, though this generally requires fiddling around with visudo(8)
and if you get things wrong may lock you out of future use of sudo(1)
. Open a root shell, make a backup of /etc/sudoers
, edit the file by running visudo
, test it, and use root shell to restore the backup of the config if things go awry. Relevant sudoers(5)
config lines would be along the lines of
# only with these args
yourloginnamehere ALL=(root) NOPASSWD: /usr/sbin/networksetup-setautoproxystate Wi-Fi off, /usr/sbin/networksetup-setautoproxystate Wi-Fi on
# any arguments to the command
yourloginnamehere ALL=(root) NOPASSWD: /usr/sbin/networksetup
# no password prompts at all from sudo ever
yourloginnamehere ALL=(ALL) NOPASSWD: ALL
Also visudo
may run a strange editor by default, so you might want to read up on the EDITOR
and DISPLAY
environment variables and related sudo
questions and documentation before you get stuck in vi
...
sudo networksetup ...
-- it will still ask for your password, just not every time.