I am able to list the password of a particular keychain item, but I need to be able to change the password using the Terminal. I intend to write a small script that will automate such a process.

Note: I need to be able to do that using the Terminal only without any GUI!

To display the password of my keychain item, I do the following:

security find-internet-password -gs my.site.com | grep "password:"

The above command works nicely. How do I change this password? For now, let's assume that the security and Keychain Access.app applications have full access to the keychain item. I eventually need to find a way to give access to that keychain item via the Terminal, without any pop-ups/GUI. I have Administrator \ sudo rights to this Mac machine.

Thank you!


If you create the password with the security utility, you can also update it.

security add-internet-password -a 'someuser@domain' -w 's0m3passw0rd' -U -s 'www.some.site -p '/optional/path' -T '/Applications/Google Chrome.app/'

you can update it with the -U flag:

security add-internet-password -U -a 'someuser@domain' -w '0therp4ssw0rd' -U -s 'www.some.site -p '/optional/path' -T '/Applications/Google Chrome.app/'

I've not found a reliable way to update passwords created by other means then the security utility. The -T flag should of course point to the application(s) you want to give access, the -T flag can be repeated multiple times for multiple applications. The -a (accountname) flag can also be any form that your username has.

  • 1
    Thank you for this update. Indeed the password has been created by other means and using your command, I only created a new keychain item of the same type and same name and they appear as two entries in the Keychain app. Very weird. – Shailen Aug 11 '16 at 12:13
  • 1
    i expect it's to do with differences between the entries which i cannot discern, maybe comparing them thoroughly and seeing if any difference could be fed in the "new" one to try to duplicate. otherwise just remove the old one, add the new one manually and then you'll be able to keep it updated from now on. You can actually use the -U flag always, so not only on update. Maybe you can fashion your script so that it both creates and update your accounts and make it predictable like that. – madeddie Aug 11 '16 at 12:15

You must log in to answer this question.

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