Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a keychain from search list?

Tags:

keychain

This is asked as a follow up as this SO:

Add a keychain to search list?

We know how to add a new create keychain to the search list by:

security list-keychains -s `security list-keychains | xargs` $NEW_KEYCHAIN

However, how do we remove it afterwords? After calling this multiple times (intentionally), we end up having this:

$ security list-keychains
"/Users/jenkins/Library/Keychains/login.keychain-db"
"/Users/jenkins/Library/Keychains/foo.keychain-db"
"/Users/jenkins/Library/Keychains/foo.keychain-db"
"/Library/Keychains/System.keychain"

Notice that we have multiple entries of foo.keychain-db there.

like image 512
Yuchen Avatar asked Oct 20 '25 11:10

Yuchen


1 Answers

This may not be ideal, but we can simply call it again with the entries that we want to keep. For example, in this case:

$ security list-keychains -s /Users/jenkins/Library/Keychains/login.keychain-db /Library/Keychains/System.keychain

And it will be the result that we want:

$ security list-keychains
"/Users/jenkins/Library/Keychains/login.keychain-db"
"/Library/Keychains/System.keychain"
like image 106
Yuchen Avatar answered Oct 23 '25 08:10

Yuchen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!