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

gnupg 2.0 Basic usage

Divesh Uttamchandani edited this page Apr 23, 2018 · 3 revisions

Some basic usage is demonstrated on the examples below.

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

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 EGPG_DIR="/home/testuser/.egpg"
#export GNUPGHOME="/home/testuser/.egpg/.gnupg"
# Does ".gpg-agent-info" exist and points to gpg-agent process accepting signals?
if ! test -f "$EGPG_DIR/.gpg-agent-info" \
|| ! kill -0 $(cut -d: -f 2 "$EGPG_DIR/.gpg-agent-info") 2>/dev/null
then
    gpg-agent --daemon --no-grab --quiet \
        --options "$EGPG_DIR/gpg-agent.conf" \
        --pinentry-program /usr/bin/pinentry \
        --write-env-file "$EGPG_DIR/.gpg-agent-info" > /dev/null
fi
### 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.0-1.1    ( https://github.com/easygnupg/egpg )

EGPG_DIR="/home/testuser/.egpg"
GNUPGHOME="/home/testuser/.egpg/.gnupg"
DONGLE=""
KEYSERVER="hkp://keys.gnupg.net"
GPG_AGENT_INFO="/tmp/gpg-YQjLty/S.gpg-agent:7838:1"
GPG_TTY="/dev/pts/22"
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: 

id: D12F18F9B50EEBB0
uid: Test User <[email protected]>
fpr: 3E64 4602 3F55 95F3 3932 6056 D12F 18F9 B50E EBB0 
trust: ultimate
sign: D12F18F9B50EEBB0 2016-06-05 2016-07-05 
decr: 0BED9B547FC71851 2016-06-05 2016-07-05 


Creating a revocation certificate.

Revocation certificate saved at: 
    "/home/testuser/.egpg/D12F18F9B50EEBB0.revoke"
    "/home/testuser/.egpg/D12F18F9B50EEBB0.revoke.pdf"

Please move it to a medium which you can hide away; if Mallory gets
access to this certificate he can use it to make your key unusable.
It is smart to print this certificate and store it away, just in case
your media become unreadable.  But have some caution:  The print system of
your machine might store the data and make it available to others!

testuser@laptop:~$ egpg info

EasyGnuPG 2.0-1.1    ( https://github.com/easygnupg/egpg )

EGPG_DIR="/home/testuser/.egpg"
GNUPGHOME="/home/testuser/.egpg/.gnupg"
DONGLE=""
KEYSERVER="hkp://keys.gnupg.net"
GPG_AGENT_INFO="/tmp/gpg-bZYIfp/S.gpg-agent:15236:1"
GPG_TTY="/dev/pts/5"
SHARE=no
DEBUG=no

id: D12F18F9B50EEBB0
uid: Test User <[email protected]>
fpr: 3E64 4602 3F55 95F3 3932 6056 D12F 18F9 B50E EBB0 
trust: ultimate
sign: D12F18F9B50EEBB0 2016-06-05 2016-07-05 
decr: 0BED9B547FC71851 2016-06-05 2016-07-05 

testuser@laptop:~$ egpg key

id: D12F18F9B50EEBB0
uid: Test User <[email protected]>
fpr: 3E64 4602 3F55 95F3 3932 6056 D12F 18F9 B50E EBB0 
trust: ultimate
sign: D12F18F9B50EEBB0 2016-06-05 2016-07-05 
decr: 0BED9B547FC71851 2016-06-05 2016-07-05 

testuser@laptop:~$ egpg key fpr

3E64 4602 3F55 95F3 3932 6056 D12F 18F9 B50E EBB0

testuser@laptop:~$ egpg key renew 1 year

id: D12F18F9B50EEBB0
uid: Test User <[email protected]>
fpr: 3E64 4602 3F55 95F3 3932 6056 D12F 18F9 B50E EBB0 
trust: ultimate
sign: D12F18F9B50EEBB0 2016-06-05 2017-06-05 
decr: 0BED9B547FC71851 2016-06-05 2017-06-05 

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

testuser@laptop:~$ egpg seal test.txt

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

You need a passphrase to unlock the secret key for
user: "Test User <[email protected]>"
4096-bit RSA key, ID 7FC71851, created 2016-06-05 (main key ID B50EEBB0)

gpg: Signature made Sun 05 Jun 2016 11:26:30 AM CEST using RSA key ID B50EEBB0
gpg: Good signature from "Test User <[email protected]>"

testuser@laptop:~$ egpg sign test.txt

You need a passphrase to unlock the secret key for
user: "Test User <[email protected]>"
4096-bit RSA key, ID B50EEBB0, created 2016-06-05

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

gpg: Signature made Sun 05 Jun 2016 04:14:09 PM CEST using RSA key ID B50EEBB0
gpg: Good signature from "Test User <[email protected]>"

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/