Generar un nuevo par de llaves
$ gpg --gen-key gpg (GnuPG) 1.4.18; Copyright (C) 2014 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? 1 RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) 2048 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 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) <heinrichh@duesseldorf.de>" Real name: Jorge I. Meza Email address: jimezam @autonoma.edu.co Comment: PGP certificate for work You selected this USER-ID: "Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co>" 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. Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 239 more bytes) gpg: key 525E50C5 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 2048R/525E50C5 2015-10-15 Key fingerprint = 3792 F014 361E 93E7 355F 7FCA C153 2279 525E 50C5 uid Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co> sub 2048R/E56672A6 2015-10-15
Listar las llaves conocidas
Las llaves públicas
$ gpg --list-keys /home/educacion/.gnupg/pubring.gpg ---------------------------------- pub 2048R/525E50C5 2015-10-15 uid Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co> sub 2048R/E56672A6 2015-10-15
Las llaves privadas
$ gpg --list-secret-keys /home/educacion/.gnupg/secring.gpg ---------------------------------- sec 2048R/525E50C5 2015-10-15 uid Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co> ssb 2048R/E56672A6 2015-10-15
Exportar mi llave pública
$ gpg --armor --export -a 525E50C5 > public.key
Importar la llave pública de otro usuario
$ gpg --import public.key
Cifrar un archivo
$ gpg --recipient 525E50C5 --armor --encrypt ARCHIVO.EXT
En este caso se utilizará la llave pública identificada por el código 525E50C5
para cifrar el archivo. Este proceso genera ARCHIVO.EXT.asc
el cual corresponde a la versión cifrada de ARCHIVO.EXT
y es el archivo que se podrá transmitir a través de un medio inseguro.
Descifrar un archivo
$ gpg --output ARCHIVO.EXT --decrypt ARCHIVO.EXT.asc
Firmar un archivo
$ gpg --detach-sign ARCHIVO.EXT
Se genera el archivo ARCHIVO.EXT.sig
el cual corresponde a la firma del archivo ARCHIVO.EXT
y se deberá transmitir junto con el archivo original.
Verificar la firma de un archivo
Se deberá contar con el archivo de la firma (.sig) y con el archivo original, así como con la llave pública de su supuesto autor.
$ gpg ARCHIVO.EXT.sig
En caso de que el documento corresponda con el expedido por el autor original se obtendrá un mensaje similar al siguiente.
gpg: assuming signed data in `ARCHIVO.EXT'
gpg: Signature made jue 15 oct 2015 12:40:56 COT using RSA key ID 525E50C5
gpg: Good signature from "Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co>"
En caso de que el documento NO corresponda con el expedido por el autor original se obtendrá un mensaje similar al siguiente.
gpg: assuming signed data in `ARCHIVO.EXT'
gpg: Signature made jue 15 oct 2015 12:40:56 COT using RSA key ID 525E50C5
gpg: BAD signature from "Jorge I. Meza (PGP certificate for work) <jimezam @autonoma.edu.co>"
Recursos
- The GNU Privacy Guard
https://gnupg.org/ - GNU Privacy Guard en Wikipedia
https://en.wikipedia.org/wiki/GNU_Privacy_Guard - Curso sencillo de PGP por Arturo Quirantes Sierra
http://www.ugr.es/~aquiran/cripto/cursopgp.htm - GPG Tutorial
https://futureboy.us/pgp.html - GnuPrivacyGuardHowto en Ubuntu Documentation
https://help.ubuntu.com/community/GnuPrivacyGuardHowto - PGP Tutorial
http://aperiodic.net/phil/pgp/tutorial.html