I'm trying to export some items on my keychain like this:

hostname:~ username$ security export -k login.keychain -t all -P "passphrase"

but I always get this error:

security: SecKeychainItemExport: Passphrase is required for import/export

What gives?

clarification: I'm logged in via SSH.


When I run

security export -t identities

I get the same error message:

security: SecKeychainItemExport: Passphrase is required for import/export.

However, if I specify a format with the -f open (and put the binary output stream into a file), it works:

security export -P testing -f pkcs12 -t identities -o test.p12

yields a file I can work with via openssl.

It looks to me like security is just using the wrong error message here, thus making it look like the feature doesn't work. It probably should be saying "You must specify a format to export private keys", or words to that effect.

The actual insight comes from this tweet.


This is just broken, IMO. 'security export' behaves very badly if you try to export private keys and you log in with SSH. Same commands work when you log in from the GUI. Is this on purpose?

Depending on what you need, you might be able to work around it with 'security find-certificates' or 'security export -t certs'. It all works as long as you don't export a private key.


If your passphrase has any odd symbols your shell is swallowing, try using single quotes instead of double to prevent interpolation.

security export -k login.keychain -t all -P 'passphrase'
  • I think this is not a quotation issue. – Charles Stewart Oct 5 '11 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.