Limpar o meu chaveiro gnupg?

36

Meu chaveiro gnupg contém centenas de entradas desnecessárias. Como eu removerei as chaves expiradas, revogadas e não assinadas dele?

Gostaria de manter as chaves que assinaram minha chave e importar novas chaves somente conforme necessário. Eu já havia importado toda a rede de confiança para os signatários da minha chave. Parece que um dos meus principais assinantes pegou um número muito grande de assinaturas em suas viagens, e agora estão entupindo meu chaveiro.

    
por scruss 11.05.2013 / 01:15

3 respostas

23

Do Folheto de dicas de GPG de Charles Lockhart :

I've used User Name as being the name associated with the key.  Sorry that isn't very imaginative.  I think gpg is pretty wide in its user assignments, e.g., the name for my private key is “Charles Lockhart”, but I can reference that by just putting in “Lockhart”.  That doesn't make any sense, sorry.

            ︙

to delete a public key (from your public key ring):

$ gpg --delete-key "User Name"

This removes the public key from your public key ring.
NOTE: If there is a private key on your private key ring associated with this public key, you will get an error! You must delete your private key for this key pair from your private key ring first.

to delete a private key (a key on your private key ring):

$ gpg --delete-secret-key "User Name"

This deletes the secret key from your secret key ring.

    
por 11.05.2013 / 09:11
7

Eu tenho um script bash programado para ser executado semanalmente no cron para lidar com isso:

#!/bin/bash
# Clean up the GPG Keyring.  Keep it tidy.
# blog.lavall.ee

echo -n "Expired Keys: "
for expiredKey in $(gpg2 --list-keys | awk '/^pub.* \[expired\: / {id=$2; sub(/^.*\//, "", id); print id}' | fmt -w 999 ); do
    echo -n "$expiredKey"
    gpg2 --batch --quiet --delete-keys $expiredKey >/dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo -n "(OK), "
    else
        echo -n "(FAIL), "
    fi
done
echo done.

echo -n "Update Keys: "
for keyid in $(gpg -k | grep ^pub | grep -v expired: | grep -v revoked: | cut -d/ -f2 | cut -d' ' -f1); do
    echo -n "$keyid"
    gpg2 --batch --quiet --edit-key "$keyid" check clean cross-certify save quit > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo -n "(OK), "
    else
        echo -n "(FAIL), "
    fi
done
echo done.

gpg2 --batch --quiet --refresh-keys > /dev/null 2>&1
if [ $? -eq 0 ]; then
    echo "Refresh OK"
else
     echo "Refresh FAIL."
fi
    
por 02.01.2015 / 20:21
4
% gpg --edit-key KEYID
gpg> clean
User ID [...]: 139 signatures removed
gpg> save
% gpg --version
gpg (GnuPG) 1.4.18
[...]
    
por 12.09.2014 / 23:15