[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Removing invalid keys from keyring



On Wed, Mar 26, 2003 at 05:28:35PM +0100, Kjetil Kjernsmo wrote:
> Is there a way to remove revoked/expired and otherwise invalid or 
> useless keys from a GPG keyring, in batch?

well, I do not know how to automatically list only "invalid" keys.
but you could do:
 # backup you keyring, in case something goes wrong ;)
 cp -a ~/.gnupg ~/.gnupg.bak
 # list all main pub keys
 gpg --list-public-keys | grep ^pub | sort > tmp.pubkey_list

 #
 # edit that file, _delete_ every line corresponding to a _valid_ key
 # 

 # now, remove all keys still in that file in one run
 cut -d " " -f 5- tmp.pubkey_list \
   | xargs -l gpg --batch --yes --delete-key

 # verify which keys are still there
 gpg --list-public-keys

hth
		Lars



Reply to: