Extend an expired gpg key for pass

GPG key expired

Recently I was greeted by pass with the following error message when trying to add a new passphrase:

gpg: [stdin]: encryption failed: Unusable public key
gpg: Note: secret key `ABCDABCD` expired at Sun 02 June 2024 16:36:45 BST`. 

Use gpg --list-keys to get a list of your keys and check their expiration date:

gpg --list-keys
pub   rsa4096 2020-06-02 [SC] [expired: 2024-06-02]
uid           [ultimate] Stefan Proell (GPG Key 2020) <stefan@example.org>
sub   rsa4096 2020-12-03 [E] [expired: 2024-06-02]

Extend the date

Simply use gpg --edit-key AAAAAAAAAABBBBBBBBBBBBBBCCCCCCCDDDDDDDDD and select the key you want to edit with its associated number (1). Then type expire and select the new duration you want the key to be valid for. Close with save. You then need to enter the password and you are done.