I am trying to create a bash script that will update the mac's proxy settings and a few other places when a user changes their password every 60 days. So far I am trying to use this command for the proxy

networksetup -setwebproxy wi-fi proxy.example.com 8080 on "$USER" "$NewPassword"

but when I run the command after the proxy has been set up, it gives an error.

networksetup[32852:1867937] error -25299 attempting to create account and password for proxy: proxy.example.com:8080

The error will only shows up when the username and password have been previously set up, but if I delete the username and password from the GUI, then run the command it will setup the authentication.

Anyone have any ideas?


You need to delete the proxy password programmatically, something like -

security delete-internet-password -s $PROXY
networksetup -setwebproxy Ethernet $PROXY 8080 on $USER $PASSWORD

Here, the -s tells it to delete the internet password that has the server set as proxy.example.com

Once it's deleted you can recreate the web proxy entries.

If you want to find the passwords to test before deleting, you can do the following, and confirm you get only one entry. You can also set a comment (use KeyChain Access), and confirm it shows up in the icmt field:

security find-internet-password -s 'proxy.example.com'
keychain: "/Users/alex/Library/Keychains/login.keychain-db"
version: 512
class: "inet"
0x00000007 <blob>="proxy.example.com"
0x00000008 <blob>=<NULL>
"cdat"<timedate>=0x32303139303231383032343431305A00  "20190218024410Z\000"
"mdat"<timedate>=0x32303139303231383032343632395A00  "20190218024629Z\000"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .