The gpg
tool needs to be installed.
Generate GPG key pair.
gpg --full-generate-key
Enter length of validity. (2y is a good one)
⚠️ Never use a key that never expires. This helps in the case the private key is lost, you will be assured that the public key will at least expire some-day, so you stop receiving messages encrypted using the lost key.
Upload the key to public key servers
gpg --send-keys <key-id>
where you can get your key id using
gpg --list-keys
References: