lock-keychain [-h] [-a|keychain]
Lock keychain, or the default keychain if none is specified. If the -a option is specified, all
keychains are locked.
unlock-keychain [-hu] [-p password] [keychain]
Unlock keychain, or the default keychain if none is specified.
set-keychain-settings [-hlu] [-t timeout] [keychain]
Set settings for keychain, or the default keychain if none is specified.
-l Lock keychain when the system sleeps.
-u Lock keychain after timeout interval.
-t timeout Specify timeout interval in seconds (omitting this option specifies "no timeout").
out").
set-keychain-password [-h] [-o oldPassword] [-p newPassword] [keychain]
Set password for keychain, or the default keychain if none is specified.
-o oldPassword Old keychain password (if not provided, will prompt)
-p newPassword New keychain password (if not provided, will prompt)
show-keychain-info [-h] [keychain]
Show the settings for keychain.
dump-keychain [-adhir]
Dump the contents of one or more keychains.
-a Dump access control list of items
-d Dump (decrypted) data of items
-i Interactive access control list editing mode
-r Dump raw (encrypted) data of items
Examples
Print all passwords stored in the default keychain this will prompt for a password (unless the keychain is already unlocked):
security dump-keychain -d ~/Library/Keychains/login.keychain
“Security is mostly a superstition. It does not exist in nature, nor do the children of men as a whole experience it. Avoiding danger is no safer in the long run than outright exposure. Life is either a daring adventure, or nothing” ~ Helen Keller
Related macOS commands:
security - Administer Keychains, keys, certificates and the Security framework.