$ gpg --list-keys
$ gpg --edit-key KEYID
Use the expire command to set a new expire date:
gpg> expire
When prompted type 1y
(recommended)
Now, this has expired the primary key (key 0). We need to repeat the process for subkeys. Select all the subkeys (A star will appear before all selected keys):
gpg> key 1
gpg> key 2
gpg> expire
Since the key has changed we now need to trust it, otherwise we will get the error "There is no assurance this key belongs to the named user" when using the key:
gpg> trust
Test it out:
echo "testing encryption" >> encry.txt
#encrytion
gpg --encrypt --sign --armor -r [email protected] encry.txt
cat encry.txt.asc
#decrytion
gpg --decrypt encry.txt.asc >> encry.new.txt
cat encry.new.txt
Backup the key:
gpg -a --export KEYID > kris.leech.gpg.public
gpg -a --export-secret-keys KEYID > kris.leech.gpg.private
Move the keys on to something like a USB drive and store it safely in another location.
Publish the public key:
gpg --keyserver keyserver.ubuntu.com --send-keys KEYID
gpg --keyserver pgp.mit.edu --send-keys KEYID
If you need to copy/paste the public key to a key server:
xclip -i kris.leech.gpgp.public -selection clipboard
Credits: https://gist.github.com/krisleech/760213ed287ea9da85521c7c9aac1df0