Sunday, July 07, 2024

GPG useful commands

List secret keys

gpg2 --list-secret-keys -v --keyid-format=long --with-subkey-fingerprints
gpg2 -K -v --keyid-format=long --with-subkey-fingerprints

List public keys

gpg2 --list-keys -v --keyid-format=long --with-subkey-fingerprints
gpg2 -k -v --keyid-format=long --with-subkey-fingerprints

Edit keys

gpg2 --edit-key xxx

Generate new key

gpg --full-generate-key

Encrypt

tar cf - tmpfile | gpg2 -u xxxx -vaser xxxx - >> tmp14.tar.gpg

tar cf tmpefile.tar tmpfile
gpg2 -u xxxx -vaser xxxx tmpefile.tar >> tmp14.tar.gpg 

gpg2 -u xxxx -o tmp14.tar.gpg -vaser xxxx tmpefile.tar

Decrypt

gpg2 -d file3.txt >> file

Show keys in a file

gpg2 -v --keyid-format=long --with-subkey-fingerprints --show-keys gpg.key

Export keys

gpg2 --export -a -o <filename>
gpg2 --export-secret-keys -a -o <filename>