Skip to content
This repository has been archived by the owner on Oct 25, 2018. It is now read-only.

gnupg 2.2 basic usage

Divesh Uttamchandani edited this page May 18, 2018 · 2 revisions

Some basic usage is demonstrated on the examples below.

testuser@laptop:~$ rm -rf ~/.egpg/

testuser@laptop:~$ killall -u $USER gpg-agent

testuser@laptop:~$ egpg

No directory '/home/testuser/.egpg'
Try first: egpg init

testuser@laptop:~$ egpg init

mkdir: created directory '/home/testuser/.egpg'

Appended the following lines to '/home/testuser/.bashrc':
---------------8<---------------
### start egpg config
export GPG_TTY=$(tty)
export EGPG_DIR="/home/testuser/.egpg"
#export GNUPGHOME="/home/testuser/.egpg/.gnupg"
### end egpg config
--------------->8---------------
Please reload it to enable the new config:
    source "/home/testuser/.bashrc"

testuser@laptop:~$ source "/home/testuser/.bashrc"

testuser@laptop:~$ egpg

EasyGnuPG 2.2-1.0    ( https://github.com/easygnupg/egpg )

EGPG_DIR="/home/testuser/.egpg"
GNUPGHOME="/home/testuser/.egpg/.gnupg"
DONGLE=""
KEYSERVER="hkp://keys.gnupg.net"
GPG_TTY="/dev/pts/18"
SHARE=no
DEBUG=no

No valid key found.

Try first:  egpg key gen
       or:  egpg key fetch
       or:  egpg key restore
       or:  egpg key recover

testuser@laptop:~$ egpg key gen [email protected] "Test User"

Creating a new key.

Enter passphrase for the new key: 
Retype the passphrase of the key: 
Please enter the passphrase to unlock the OpenPGP secret key:
"Test User <[email protected]>"
4096-bit RSA key, ID 01D532A283DC1CBF,
created 2016-06-06.

Passphrase: 

id: 01D532A283DC1CBF
uid: Test User <[email protected]>
fpr: 4E91 DD0E EDD7 49F2 B6DE D9CE 01D5 32A2 83DC 1CBF 
trust: ultimate
sign: 01D532A283DC1CBF 2016-06-06 2016-07-06 
decr: 7BD4B1BE5D76CC0D 2016-06-06 2016-07-06 

Revocation certificate is at: 
    "/home/testuser/.egpg/.gnupg/openpgp-revocs.d/4E91DD0EEDD749F2B6DED9CE01D532A283DC1CBF.rev"
    "/home/testuser/.egpg/.gnupg/openpgp-revocs.d/4E91DD0EEDD749F2B6DED9CE01D532A283DC1CBF.rev.pdf"

testuser@laptop:~$ egpg info

EasyGnuPG 2.2-1.0    ( https://github.com/easygnupg/egpg )

EGPG_DIR="/home/testuser/.egpg"
GNUPGHOME="/home/testuser/.egpg/.gnupg"
DONGLE=""
KEYSERVER="hkp://keys.gnupg.net"
GPG_TTY="/dev/pts/18"
SHARE=no
DEBUG=no

id: 01D532A283DC1CBF
uid: Test User <[email protected]>
fpr: 4E91 DD0E EDD7 49F2 B6DE D9CE 01D5 32A2 83DC 1CBF 
trust: ultimate
sign: 01D532A283DC1CBF 2016-06-06 2016-07-06 
decr: 7BD4B1BE5D76CC0D 2016-06-06 2016-07-06 

testuser@laptop:~$ egpg key

id: 01D532A283DC1CBF
uid: Test User <[email protected]>
fpr: 4E91 DD0E EDD7 49F2 B6DE D9CE 01D5 32A2 83DC 1CBF 
trust: ultimate
sign: 01D532A283DC1CBF 2016-06-06 2016-07-06 
decr: 7BD4B1BE5D76CC0D 2016-06-06 2016-07-06 

testuser@laptop:~$ egpg key fpr

4E91 DD0E EDD7 49F2 B6DE D9CE 01D5 32A2 83DC 1CBF

testuser@laptop:~$ egpg key renew 1 year

Please enter the passphrase to unlock the OpenPGP secret key:
"Test User <[email protected]>"
4096-bit RSA key, ID 01D532A283DC1CBF,
created 2016-06-06.

Passphrase: 

id: 01D532A283DC1CBF
uid: Test User <[email protected]>
fpr: 4E91 DD0E EDD7 49F2 B6DE D9CE 01D5 32A2 83DC 1CBF 
trust: ultimate
sign: 01D532A283DC1CBF 2016-06-06 2017-06-06 
decr: 7BD4B1BE5D76CC0D 2016-06-06 2017-06-06 

testuser@laptop:~$ echo "This is a test message." > test.txt

testuser@laptop:~$ egpg seal test.txt

Please enter the passphrase to unlock the OpenPGP secret key:
"Test User <[email protected]>"
4096-bit RSA key, ID 01D532A283DC1CBF,
created 2016-06-06.

Passphrase: 

testuser@laptop:~$ egpg open test.txt.sealed

Please enter the passphrase to unlock the OpenPGP secret key:
"Test User <[email protected]>"
4096-bit RSA key, ID 7BD4B1BE5D76CC0D,
created 2016-06-06 (main key ID 01D532A283DC1CBF).

Passphrase: 
gpg: Signature made Mon 06 Jun 2016 06:28:52 PM CEST
gpg:                using RSA key 01D532A283DC1CBF
gpg: Good signature from "Test User <[email protected]>" [ultimate]

testuser@laptop:~$ egpg sign test.txt

Please enter the passphrase to unlock the OpenPGP secret key:
"Test User <[email protected]>"
4096-bit RSA key, ID 01D532A283DC1CBF,
created 2016-06-06.

Passphrase: 

testuser@laptop:~$ egpg verify test.txt.signature

gpg: Signature made Mon 06 Jun 2016 06:32:23 PM CEST
gpg:                using RSA key 01D532A283DC1CBF
gpg: Good signature from "Test User <[email protected]>" [ultimate]

testuser@laptop:~$ egpg key revoke

Revocation will make your current key useless.
You'll need to generate a new one.
Are you sure about this? [y/N] y

testuser@laptop:~$ egpg key ls

No valid key found.

Try first:  egpg key gen
       or:  egpg key fetch
       or:  egpg key restore
       or:  egpg key recover

testuser@laptop:~$ rm -rf ~/.egpg/