GnuPG : key commands
Below is a list of main commands for operating GnuPG
Generate double keys:
gpg --gen-key
List available keys:
gpg --list-keys
Exporting your public key:
gpg --armor --export keyID
Importing a key:
gpg --import filename
Calculating the fingerprint of a key:
gpg --fingerprint keyed
Signing a key:
gpg --sign-key keyed
Encrypt and signing a message:
gpg -sea -r keyID then type the message followed by key button
CTRL+Z
Signing a public message:
gpg --clearsign -a -r keyID then type the message followed by key
CTRL+Z
Decrypt a message/verify signature:
gpg < message.txt
Encrypt a file with a password:
gpg –c filename
Decrypt a file with password:
gpg filename
Sign a file (signature in a separate file):
gpg --armor --detach-sign filename (This will be created as filename.asc with the message)
Verifying detached signature file .asc:
gpg filename.asc
Storage keyring
The public and private keys are stored in the storage keyring namely pubring.gpg for public keys and secring.gpg for private keys.
This file is located in
~/.gnupg for Linux and POSIX OS.
Under windows Operating Systems, it is located in:
C:\Documents and Settings\votrelogin\Application Data\gnupg\
To access pubring.gpg, execute the following command :
gpg --list-keys
Public Key servers
Below is the server’s public key PGP/GPG used for publishing public keys or searching for others.
Below is a recommended server due to its efficiency in deleting invalid keys automatically.
https://keyserver.pgp.com/