Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How can I set enable HTTP and/or HTTPS Proxies through command line?

I know the exact key/value to be changed; it's in

/Library/Preferences/SystemConfiguration/preferences.plist -> NetworkServices -> 46A40FA8-6E7C-xxxx-xxxx-xxxxxxxxxxx -> Proxies -> HTTP(S)Enable -> should be set to 1


I immdediately thought of using defaults write to carry this out in the command line but I don't know how (or if at all!) that works with multi-level key/values. I only have access to the first level (NetworkServices) with defaults read.

Any help would be much appreciated,

thanks 🙂 \.

OS X Mountain Lion (10.8.3)

Posted on Apr 6, 2013 1:26 PM

Reply
4 replies

Apr 6, 2013 2:09 PM in response to Koohyar Hadjisalimi

Okay so thanks to this thread https://discussions.apple.com/thread/1315159

I could use PlistBuddy (located in /usr/libexec) to set the key HTTP(S)Enable to 1, and then save it:


sudo /usr/libexec/PlistBuddy -c "Set NetworkServices:46A40FA8-6E7C-xxxx-xxxx-xxxxxx:Proxies:HTTPSEnable 0" /Library/Preferences/SystemConfiguration/preferences.plist


sudo /usr/libexec/PlistBuddy -c Save /Library/Preferences/SystemConfiguration/preferences.plist


but my connection doesn't feel a thing! There's no indication of it working in the browser and when I go to Network Preferences, the HTTP and HTTPS proxies are still unchecked.

Do I need to 'restart' any service for this to take effect?\.

Apr 6, 2013 2:48 PM in response to Koohyar Hadjisalimi

Well I find the final solution (and this is awkwardly turning into an internal dialogue!)

In this same thread: https://discussions.apple.com/thread/1315159 there's notion of a very powerful interface called networksetup located in /usr/sbin/networksetup a quick look at its manual page tells quite a lot about its capabilites.

So the two simple commands for enabling/disabling HTTP and HTTPS are:

$ /usr/sbin/networksetup -setwebproxystate Wi-Fi [on|off]

$ /usr/sbin/networksetup -setsecurewebproxystate Wi-Fi [on|off]


\.

Apr 7, 2013 8:31 AM in response to Koohyar Hadjisalimi

FWIW, some previous (older) discussions of establishing automatic DHCP settings for web proxies, if that might be of interest to you.


https://discussions.apple.com/thread/2606796?start=0&tstart=0

https://discussions.apple.com/thread/2516293?start=0&tstart=0

https://discussions.apple.com/thread/2309560?start=0&tstart=0


The DHCP Option Code Utility tool mentioned there is still posted around the 'net, but it's no longer available via me.com. I don't know that it works on recent versions. I'd see if the wpad stuff works without that.


Some of the older forum postings have problems with the underscores in symbols, and have corresponding mistranslated those as underlining.

Apr 7, 2013 11:07 AM in response to Koohyar Hadjisalimi

The networksetup utility is the program OS X uses to change the network configuration. The Network Preference Pane in system preferences is just a front end to networksetup; networksetup can do everything the preference pane can do (and possibly more).


The parameters you are interested in (from the man page):



-getwebproxy networkservice


Displays Web proxy (server, port, enabled value) info for <networkservice>.



-setwebproxy networkservice domain portnumber authenticated username password


Set Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.



-setwebproxystate networkservice on | off


Set Web proxy on <networkservice> to either <on> or <off>.



-getsecurewebproxy networkservice


Displays Secure Web proxy (server, port, enabled value) info for <networkservice>.



-setsecurewebproxy networkservice domain portnumber authenticated username password


Set Secure Web proxy for <networkservice> with <domain> and <port number>. Turns proxy on. Optionally, specify <on> or <off> for <authenticated> to enable and disable authenticated proxy support. Specify <username> and <password> if you turn authenticated proxy support on.



-setsecurewebproxystate networkservice on | off


Set SecureWeb proxy on <networkservice> to either <on> or <off>.

How can I set enable HTTP and/or HTTPS Proxies through command line?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.