Quantcast
Channel: BSDnexus
Viewing all articles
Browse latest Browse all 17

gpg quick guide

$
0
0

GENERATE KEY PAIR

Generate personal key pair (private and public)

gpg --gen-key

You will be prompted for a password for private key

LISTING / VIEWING KEYS IN KEYRING

List public keys in your gpg keyring

gpg --list-keys [key_reference]

example output:

/home/jondoe/.gnupg/pubring.gpg
-----------------------------
pub   1024D/1A2B3C4D 2013-09-10
uid                  Jon Doe (a user) <jon.doe@example.com>
sub   2048g/F5E4D3C2 2013-09-10

The “1A2B3C4D” is the key reference for the key listed above. The appropriate key reference should be used where any example on this page writes “key_reference”

List secret keys in your gig keyring

gpg --list-secret-keys

PUBLIC KEYS

Export a public key to a file ‘public.key’

gpg --export -a key_reference > public.key

Import a public key in the file ‘public.key’

gpg --import public.key

Delete a public key

gpg --delete-key -a key_reference

NOTE – if the public key has a private key in the keychain it cannot be deleted until the private key is deleted

PRIVATE KEYS

Export a private key

gpg --export-secret-key -a key_reference > private.key

Import a private key in file ‘private.key’

gpg --allow-secret-key-import --import private.key

Delete a private key

gpg --delete-secret-key -a key_reference

ENCRYPTING FILES

Encrypt a file with a public key

gpg -e -r key_reference file.ext

NOTE – a new file file.ext.gpg is created, but the original file.ext still exists and needs to be deleted manually if so wished

DECRYPT FILES

You will be prompted for the password for the private key related to the public key used for encryption. If you do not have the private key you cannot decrypt the file

gpg -d file.ext.gpg > file.ext

Viewing all articles
Browse latest Browse all 17

Trending Articles