PGP Key

Table of contents
  1. OpenPGP
  2. GnuPG
    1. Basic usage
    2. Editing a key
    3. Encrypt and decrypt
    4. Error
  3. Key ID
    1. Fingerprint
    2. Long key ID
    3. Short key ID

OpenPGP

To be added


GnuPG

Basic usage

# Follow prompt to create keys
gpg --full-generate-key

# List public keys
gpg --list-keys

# List secret keys
gpg --list-secret-keys

Editing a key

gpg --edit-key <key-id>

To fix the expiration setting, for example, do:

gpg> expire
...prompt...

Then save the settings by:

gpg> save

Related files will be stored in ~/.gnupg.

Encrypt and decrypt

To be added

The last % of decrypted output is unused.

Error

In case you get any error of the following:

$ gpg: public key decryption failed: Inappropriate ioctl for device
$ gpg: decryption failed: Inappropriate ioctl for device

or

$ gpg: public key decryption failed: No such file or directory
$ gpg: decryption failed: No such file or directory

Try:

echo $GPG_TTY

If it shows a not a tty error, set:

export GPG_TTY=$(tty)

You can place them in your shell configuration file.


Key ID

The key ID is calculated from your public key and the creation timestamp.

Fingerprint

The long hex printed with gpg --list-keys is the fingerprint of the key.

Long key ID

The last 16 hex of the fingerprint.

Short key ID

The last 8 hex of the fingerprint.

You can provide either one of the three for a key ID.