[英]How to delete a keychain reference from command line
該delete-keychain
命令行選項來security
刪除鑰匙串文件,並從鑰匙扣的搜索列表中刪除。 要從搜索列表中刪除鑰匙串的引用,請使用list-keychains -s
,在刪除要消失的列表的同時重寫列表。
在命令行中,引用由list-keychains
處理,數據庫/keychain-file 由delete-keychain
處理。
# Get a list of user keychains, make a note of the names
security list-keychains -d user
# Create a new keychain
security create-keychain -p password MyNew.keychain
# Adjust the 'references' by rewriting the search list
security list-keychains -s MyNew.keychain <space separated list of other keychains>
# Delete the keychain
security delete-keychain MyNew.keychain
您可以使用rm
命令直接刪除文件。 位置將是以下之一,具體取決於鑰匙串是在system
域還是user
域中。
系統域鑰匙串位置
$ ls -l /Library/Keychains/
total 392
-rw-r--r-- 1 root wheel 20460 Aug 21 2014 ConnectedBackup.keychain
-rw-r--r-- 1 root wheel 23732 Aug 21 2014 FileVaultMaster.keychain
-rw-r--r-- 1 root wheel 89560 Sep 19 21:37 System.keychain
-rw-r--r-- 1 root wheel 20460 Nov 10 2014 System.keychain-orig
用戶域鑰匙串位置
$ ls -l ~/Library/Keychains/
total 1392
drwx------ 8 Kevin 1437522721 272 Jul 1 2015 386EC17D-8428-522E-B9DD-CE89C60F0F10
-rw-r--r--@ 1 Kevin 1437522721 40776 Jan 25 2016 Microsoft_Entity_Certificates
-rw-r--r--@ 1 Kevin 1437522721 34368 Jan 25 2016 Microsoft_Intermediate_Certificates
-rw-r--r--@ 1 Kevin 1437522721 513136 Sep 27 20:05 login.keychain
-rw------- 1 Kevin 1437522721 87552 Sep 28 16:59 metadata.keychain
所以如果你想從用戶域中刪除login
鑰匙串,你會
$ rm -rf ~/Library/Keychains/login.keychain
(出現在鑰匙串實用程序中的鑰匙串名稱是沒有后綴.keychain
文件名)
編輯
macOS Sierra 及更高版本具有-db
擴展名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.