Batch update Apple Keychain passwords using terminal

This should be possible with security(1).

The command should like something like this:

security add-generic-password -a 10.18.124.1 -w "newpw" -j "Password Updated 2017-05-17 12:04" -U
  • -a Specify account name (required)
  • -w Specify password to be added
  • -j Specify comment string (optional)
  • -U Update item if it already exists

I don't think there is a "contains" feature so you maybe have to loop this.