GPG Cheatsheet

Create Key

You may want to follow this guide.

gpg --gen-key  

Display All Keys

gpg --list-keys  

Display Public Keys

gpg --list-public-keys  

Display Private Keys

gpg --list-secret-keys  

Exporting Public Keys

If you just want other's to be able to send you encrypted messages, you just need to give them your public key. The public key can only be used for encrypting messages, so you can pretty much give it to anybody.

To export all public keys, execute:

gpg --export -a > [filename].asc  

If you want to export a single public key, then you need to also specify some sort of identifier, such as the email address or the key user's name

gpg --export -a "blah@gmail.com" > [filename].asc  
  • The -a switch is for --armour or --armor (both supported) and converts from binary output to ascii so that one can transfer the file to any computer safely.
  • Other's quite often use the .key extension. The asc extension is to represent the fact that it is in ascii format.

Exporting Private Keys

If you own multiple computers, or are about to reinstall your operating system, you may need to export your private key. Your private key can be used to decrypt files, so be careful how you store it or send it anywhere.

To export all private keys, execute:

gpg --export-secret-key -a > [filename].asc  

If you want to export a single private key, then you need to also specify some sort of identifier, such as the email address or the key user's name

gpg --export-secret-key -a "blah@gmail.com" > [filename].asc  
  • The -a switch is for --armour or --armor (both supported) and converts from binary output to ascii so that one can transfer the file to any computer safely.
  • Other's quite often use the .key extension. The asc extension is to represent the fact that it is in ascii format.

Import Key(s)

What use is exporting keys if you couldn't import them?

gpg --import [filename]  

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus