How to I change the password of a keychain item from the Terminal?

Solution 1:

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.