I'm doing some remote Mac administration and finding myself needing to copy a keychain to the machine and then add it to the default list of keychains.

Using VNC and the GUI, this is simple: just double-click it and Keychain Access opens, revealing that it's been added. But how do you do this via terminal over SSH, so that it can be scripted? The security tool doesn't seem to have an "add-keychain" command or an argument to any other command that would do this, as far as I can tell.

How do you do this?

1 Answer 1


For some reason, the feature is hidden in the form of the -s argument to list-keychains. The other gotcha is that you need to simultaneously re-add all existing keychains. This should take care of it:

security list-keychains -s `security list-keychains | xargs` [path to keychain you want to add]
  • 2
    A breakdown of the command for people like me who are not familiar with Linux commands structure. This command appends the new keychain to the existing keychains. The security command inside the backticks prints out the existing keychains and the xargs command removes newlines.
    – fortytwo
    Commented Feb 17, 2020 at 5:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .