Silk Road forums

Discussion => Newbie discussion => Topic started by: windmillz on January 18, 2013, 11:36 pm

Title: Guide to GPG in the terminal
Post by: windmillz on January 18, 2013, 11:36 pm
Thought I would create a guide to help people with GPG in the terminal.


Step 1: Create a new key-pair

$ gpg --gen-key

       (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc.
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.

   Please select what kind of key you want:
         (1) RSA and RSA (default)
         (2) DSA and Elgamal
         (3) DSA (sign only)
         (4) RSA (sign only)
         Your selection?

   DSA keypair will have 1024 bits.
   ELG-E keys may be between 1024 and 4096 bits long.

   What keysize do you want? (2048)
   Requested keysize is 2048 bits
   Please specify how long the key should be valid.
            0 = key does not expire
           = key expires in n days
         w = key expires in n weeks
         m = key expires in n months
         y = key expires in n years

   Key is valid for? (0)
   Key does not expire at all
   Is this correct? (y/N) y

   You need a user ID to identify your key; the software
         constructs the user ID
   from the Real Name, Comment and Email Address in this form:
       "Heinrich Heine (Der Dichter) "

Real name: Alli Fairfield
Email address: alli@gmail.com
Comment: exkey

You selected this USER-ID:
    "Alli Fairfield (exkey) "

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
   You need a Passphrase to protect your secret key.

Enter passphrase:
Repeat passphrase:

We need to generate a lot of random bytes. It is a good idea
to perform some other action (type on the keyboard, move the
mouse, utilize the disks) during the prime generation; this
gives the random number generator a better chance to gain
enough entropy.

   .+++++++++++++++++++++++++.+++++++++++++++++++++++
   gpg: key 90130E51 marked as ultimately trusted
   public and secret key created and signed.

   gpg: checking the trustdb
   gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
   gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
   pub   1024D/90130E51 2010-01-02                                                    <-------(90130E51 is the Public [keyname])
   Key fingerprint = B8BD 46EF 41E7 44B9 F934  7C47 3215 5713 9013 0E51
   uid  Alli Fairfield (exkey)
   sub   2048g/35C5BCDB 2010-01-02                                                   <-------(35C5BCDB is the private keyname)


Step 2: Export the new public key (to post it on the forums for example)
- You can do this by printing it in the terminal, or creating a file with the publickey in it.

***To print out key to terminal***
$ gpg --armor --export [keyname]                                             <------(This will print to terminal where you can copy,paste etc...)

***To create a file with key***
$ gpg --armor --export [keyname] > filenameuptoyou.asc    <-----(will pop up in your home folder, open it with gedit, or whatev 
                                                                                                                   you would like to use it with)

Step 3: How to Import someones public key                      <------(So you can use their public key to encrypt messages to them)
$ gpg -import [file]


Step 4: Send a encryped message
~Ex. Sally would like to send a encrypted message to Edward. Sally Imports Edwards public key then uses this command to encrypt the file with the message in it.

$ gpg --recipient Edward --armor --encrypt [filename]          <-------(this creates the encrypted message in the same folder as the
                                                                                                                    message, default is probably your home folder if its on your     
                                                                                                                    Desktop make sure you $ cd Desktop before or else it wont
                                                                                                                    work. <correct me if im worng)

Step 5: Decrypt a Message someone sent you
$ gpg --decrypt [filename.asc]                                         <--------(This will print message details in terminal window)

~If you prefer a text file with the decrypted message use:
$ gpg --decrypt text.asc > file.txt

~Enter passphrase you created for the key-pair of the puclic key used to encrypt the message.

Also If you would like to veiw all your key-pairs use:
$ gpg --list-keys


Hope this well help a bit, If you have any questions feel free to ask!

Title: Re: Guide to GPG in the terminal
Post by: Palmergbl on March 14, 2013, 06:39 pm
cant help