19.2. 常用命令

下面列出的命令是我们经常使用的一些命令,但还有很多其他命令。请查看手册页以获取更多详细信息和信息。

首先,如果这是首次使用 GnuPG 软件以使用其加密功能,我们必须创建一个新的密钥对(公钥和私钥)。

  1. 要创建一个新的密钥对,请使用以下命令
              [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. 我们使用以下命令再次启动 GnuPG
                [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.
                      

一个新的密钥对(私钥和公钥)在 root 用户的主目录中创建~/root.