GPG installation and basic usage
Which tool should I choose gpg or gpg2?
GPG2 is just wrapper around gpg with some additional tools and can’t work without gpg installed.
Installation process
lsb_releasse -a
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Install GnuPG2
sudo apt-get update
sudo apt-get install gnupg2
Generate your identity or key pair
gpg2 --full-generate-key
List keys
gpg2 --list-public-keys
gpg2 --list-secret-keys
Export keys to file (can be transported)
gpg2 --output user.public.pgp --armor --export user@user.com
gpg2 --output user.private.pgp --armor --export-secret-key user@user.com
Import keys from file
gpg2 --import user.public.pgp
gpg2 --import user.private.pgp
Encrypt file
# recipient - which publick key to use
# new file is created in the current directory file.gpg
gpg2 --encrypt --recipient user@user.com file.txt
Cleanup original unencrypted file
shred -u file.txt
Decrypt file
gpg2 --output file.<ext> --decrypt file.gpg