0

I have a gpg keyring with keys of various sizes in it. I would like to split this keyring by key size. For maximum generality I would like to put the keys <2048 bit into one file and those >=2048 bit into another keyring file but for the immediate problem separating keys of exactly 1024 bits from keys of other sizes would suffice.

Is there any easy way to do this?

I would be doing this on Debian and would want a soloution using tools available in the Debian archive.

1

This answer covers the immediate problem but I would still appreciate a cleaner answer and one that covers the more general case.

gpg --keyring ./old.gpg --no-default-keyring --export `gpg --keyring ./old.gpg --no-default-keyring --list-keys --with-colons | grep '^pub:[^:]:1024:' | cut -d ':' -f 5` > 1024.gpg
gpg --keyring ./old.gpg --no-default-keyring --export `gpg --keyring ./old.gpg --no-default-keyring --list-keys --with-colons | grep '^pub:' | grep -v '^pub:[^:]:1024:' | cut -d ':' -f 5` > other.gpg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.