19.2. Often used Commands

The commands listed below are some that we use often, but many more exist. Check the man page for more details and information.

First of all, we must create a new key-pair (public and private) if this is a first use of the GnuPG software to be able to use its encryption features.

  1. To create a new key-pair, use the following command:

    
          [root@deep] /# gpg --gen-key
              
    
          gpg (GnuPG) 1.0.1; Copyright (C) 1999 Free Software Foundation, Inc.
              This program comes with ABSOLUTELY NO WARRANTY.
              This is free software, and you are welcome to redistribute it
              under certain conditions. See the file COPYING for details.
    
              gpg: /root/.gnupg: directory created
              gpg: /root/.gnupg/options: new options file created
              gpg: you have to start GnuPG again, so it can read the new options file
              This asks some questions and then starts key generation.
              

  2. We start GnuPG again with the following command:

    
            [root@deep] /# gpg --gen-key
                
                  
              gpg (GnuPG) 1.0.1; Copyright (C) 1999 Free Software Foundation, Inc.
              This program comes with ABSOLUTELY NO WARRANTY.
              This is free software, and you are welcome to redistribute it
              under certain conditions. See the file COPYING for details.
    
              gpg: /root/.gnupg/secring.gpg: keyring created
              gpg: /root/.gnupg/pubring.gpg: keyring created
              Please select what kind of key you want:
              (1) DSA and ElGamal (default)
              (2) DSA (sign only)
              (4) ElGamal (sign and encrypt)
              Your selection? 1
              DSA keypair will have 1024 bits.
              About to generate a new ELG-E keypair.
              minimum keysize is  768 bits
              default keysize is 1024 bits
              highest suggested keysize is 2048 bits
              What keysize do you want? (1024) 2048
              Do you really need such a large keysize? y
              Requested keysize is 2048 bits
              Please specify how long the key should be valid.
              0 = key does not expire
              <n>  = key expires in n days
                <n>w = key expires in n weeks
                  <n>m = key expires in n months
                    <n>y = key expires in n years
                      Key is valid for? (0) 0
                      correct (y/n)? y
    
                      You need a User-ID to identify your key; the software constructs the user id
                      from Real Name, Comment and Email Address in this form:
                      "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
    
                      Real name: Gerhard Mourani
                      Email address: gmourani@videotron.ca
                      Comment: [Press Enter]
                      You selected this USER-ID:
                      "Gerhard Mourani <gmourani@videotron.ca>"
    
                      Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
                      You need a Passphrase to protect your secret key.
    
                      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.
                      +++++..+++++++++++++++..+++++.++++++++++++++++++++++++++++++++++++++++..+++++++
                      +++.+++++++++++++++++++++++++.+++++++++++++++...+++++++++++++++++++++++++.+++++
                      ..+++++>+++++...+++++++++++++++>+++++.......>+++++.......>+++++................
                      ..........+++++^^^^
                      public and secret key created and signed.
                      

A new key-pair is created (secret and public key) in the root home directory ~/root.