encryption with gpg

Generate key

1
$ gpg --gen-key
Copied!

List keys

1
$ gpg --list-keys
Copied!

Encrypt Data

With a passprhare
1
$ gpg -ca -o output.txt.gpg input.txt
Copied!
with a certificate and from STDOUT
1
$ gpg -ea
Copied!
or if you know the name already (can be key, name or email)
1
$ gpg -ea -r "Ahmy"
Copied!

Decrypt Data

1
$ gpg -d file.txt.gpg
Copied!

Export

Public key
1
$ gpg --export -a "name" > public.key
Copied!
-a is to create armored ascii output.
Private Key
1
$ gpg --export-secret-key -a "name" > private.key
Copied!

Import

Public key
1
$ gpg --export-secret-key -a "name" > private.key
Copied!
Private Key
1
$ gpg --allow-secret-key-import --import private.key
Copied!

Deleting

Public Key
1
$ gpg --delete-key "Real Name"
Copied!
Private Key
1
$ gpg --delete-secret-key "Real Name"
Copied!

Extend the expiration

1
gpg --edit-key "name"
Copied!
Select the key to extend
1
gpg> key 1
2
gpg> expire
Copied!

Send key to a key server

1
gpg --keyserver keyserver.ubuntu.com --send-key "name"
Copied!
Last modified 30d ago