How can I export / import a single keychain item via the command line in OS X?

1

OS X has a command line tool called security that is made for working with keychains. The man page has examples of how to export all items of a specific type / all items for a specific keychain - but I don't understand how to export / import a single item.

What I would really like to do is update the password on a single IPSec XAuth Password item but I think maybe exporting, possibly deleting, then importing would be the closest thing to what I want.

I haven't had any luck finding examples or related questions for this task, and I've not used the security tool other than to list available keychains.

cwd

Posted 2013-11-22T04:26:03.290

Reputation: 13 508

Answers

0

You can use find-generic-password or find-internet-password:

security find-generic-password -l 'keychain item name'
security find-internet-password -s accounts.google.com

-l mathes a label and -s matches a server string. Add -w to only print the password.

Lri

Posted 2013-11-22T04:26:03.290

Reputation: 34 501

did you find an answer to importing it back in? – Chris Hough – 2016-07-28T00:17:32.080

you are awesome! is there any way to change the stored value (i.e. save it back into the keychain?) – cwd – 2013-11-22T23:52:35.567