Deleting the system keychain from Mac, specified keychain could not be found

27,672

Let's go over the terminology:

System.keychain and login.keychain are keychains. These contain keychain items like password items and secure note items.


security delete-keychain deletes an entire keychain. That's what my first comment was about: You usually do not want to delete the System keychain, including all its entries. You use this if you create your own keychains for specific uses.

security delete-keychain "/Users/danielbeck/Library/Keychains/Test.keychain"

Use security delete-generic-password, security delete-internet-password, or security delete-certificate, depending on the kind of item you want to delete, instead.

The following command deletes an item, e.g. a Secure Note, named note from the specified keychain Test2.keychain:

security delete-generic-password -l note "/Users/danielbeck/Library/Keychains/Test2.keychain"

For information about the options that allow you to specify which items to delete, see man security.

Share:
27,672

Related videos on Youtube

chitnisprasanna
Author by

chitnisprasanna

Updated on September 18, 2022

Comments

  • chitnisprasanna
    chitnisprasanna over 1 year

    I want to delete Keychain stored in System.keychain folder on Mac. I tried the following,

    security delete-keychain Keychain_name
    

    but got the following error:

    The specified keychain could not be found

    How can I remove the keychain? When it didn't work I tried giving the path where the keychain is stored

    security delete-keychain Keychain_name /Library/Keychains/System.keychain
    

    But even then I am getting the same error message.

    I want to delete it as I'm developing applications, some of the information is stored as such. If i try to delete a single item it gives the above error.

    However, When I used the following command

    sudo security delete-keychain /Library/Keychains/System.keychain 
    

    it deleted the entire System.keychain.

    Where am I going wrong in deleting single item from system.keychain?

    • HikeMike
      HikeMike over 12 years
      Try it just by specifying system.keychsin, not the full path. And your question asks about deleting the entire keychain, not a single item, therefore the question.
  • chitnisprasanna
    chitnisprasanna over 12 years
    Thanks for your reply it was very helpful...but i got another problem when i use the delete command in terminal it succeeds but when i try to delete it using script it is not getting deleted
  • HikeMike
    HikeMike over 12 years
    @chitnisprasanna I suggest you create a new question about that, providing much more information. What kind of script, the exact command you're executing, how others can replicate the issue you're experiencing, etc.