Some time ago I've decided to share a post about making yourself a perfect GPG keypair that covered the basics around creating a perfect GPG key.

Here is a little extra that can be usefull for every day job.

1.Listing keys

List all your keys in local keyring.

gpg -k, --list-keys        - list public keys
gpg -K, --list-secret-keys - list private keys

2.Exporting keys

Export selected public key to a file

gpg --armour --export "<keyID>" > pubkey.asc

3.Importing keys

gpg --import pubkey.asc

4.Searching for keys

Lets assume our remote key server will be

gpg --keyserver --search-keys "<keyID>"

5.Submitting keys to a keyserver

gpg --keyserver --send-key <keyID>

6.Fetching keys from a keyserver

gpg --keyserver --recv-keys <keyID>

7.encrypting files

To sign a document you first need a public key of a reciptient. So either import it from a file or search for it on a remote server and download to your keyring.

gpg --encrypt --armor --output file.txt.asc --recipient <keyID> file.txt

8.Decrypting files

gpg --output file --decrypt file.txt.asc

9.Sign a file (detached signature)

will create signature in file.txt.sig

gpg -b file.txt 

10.Sign a file (clearsign signature)

file contents will be embedded between the PGP signed message

gpg --clearsign < file.txt > signed-file.txt

11.Sign other people

a. fetch key from the key server
b. edit that key and type in 'SIGN'
c. push the signature to the keyserver or alternatively, export this and send it to them in an email.

gpg --keyserver --recv-keys <keyID>

gpg --edit-key <keyID>

gpg --keyserver --send-keys

12.Verify a signed file (detached signature)

gpg --verify file.txt.sig

13.Verify a signed file (clearsign signature)

gpg --verify < signed-message.txt 

14.Verify signed key

gpg --check-sigs <keyID>

Finally everyting in one place!