Una clave de gpg la vamos a necesitar en todos los casos, excepto en la validación de otras claves, con lo cual, si lo que nos interesa realmente es verificar datos firmados digitalmente por otros (como un pedazo de software), no es necesario crear una clave. Pero bueh!, yo lo primero que pensé cuando lei sobre gpg fue ¿Cómo creo mi clave?, ¿Cómo creo mi clave? ¿Cómo creo mi clave?, en fin ... ese soy yo.
El comando para crear una clave de gpg es el siguiente:
Un ejemplo de lo que la opción --gen-key pregunta es el siguiente:
[danx@dorita:danx] gpg --gen-key
gpg (GnuPG) 1.0.6; Copyright (C) 2001 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: /home/danx/.gnupg: directory created
gpg: /home/danx/.gnupg/options: new options file created
gpg: you have to start GnuPG again, so it can read the new options file
[danx@dorita:danx] gpg --gen-key
gpg (GnuPG) 1.0.6; Copyright (C) 2001 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: /home/danx/.gnupg/secring.gpg: keyring created
gpg: /home/danx/.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) 1024
Requested keysize is 1024 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) 1y
Key expires at Mon Feb 3 17:37:09 2003 ART
Is this 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: Daniel E. Coletti
Email address: dcoletti@cafelug.org.ar
Comment: CaFeLUG - Argentina
You selected this USER-ID:
"Daniel E. Coletti (CaFeLUG - Argentina) <dcoletti@cafelug.org.ar>"
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.
.+++++.++++++++++..++++++++++.++++++++++++++++++++.+++++++
++++++++...+++++++++++++++++++++++++.+++++++++++++++++++++
++++++++++++++.+++++.++++++++++........... >+++++.........
..........................................................
..................................+++++
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.
[danx@dorita:danx]
Si ves con detalle la salida del comando, verás que este comando lo tuve que
ejecutar dos veces,
el tema es que esta prueba la hice con un usuario nuevo (danx) y éste no
tenía creado el directorio ~/.gnupg/, necesario para guardar los
archivos (bases de datos con las claves publicas y privadas) que necesita el
gpg para trabajar.
En la segunda ejecución del comando el gpg preguntó lo siguiente:
Finalmente nos pregunta si esta todo correcto y la frase que sella la clave que estamos generando, este frase es importante y se recomienda fuertemente que se utilize una frase (que contenga espacios). Por supuesto, esto no debe ser algo sumamente extenso, ya que esta frase la vamos a tener que escribir una y otra vez, en cada operación de encripción, descencripción y al firmar digitalmente algo.