informatica:linux:claves_gpg
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
informatica:linux:claves_gpg [2009/12/17 15:26] – 87.221.36.107 | informatica:linux:claves_gpg [2014/09/15 10:18] – jose | ||
---|---|---|---|
Line 6: | Line 6: | ||
aptitude install gnupg | aptitude install gnupg | ||
+ | |||
Line 136: | Line 137: | ||
Como dice el texto, es necesario generar actividad en el pc (mover el ratón, navegar por internet...). Puede tardar varios minutos. | Como dice el texto, es necesario generar actividad en el pc (mover el ratón, navegar por internet...). Puede tardar varios minutos. | ||
+ | |||
+ | *Truco* | ||
+ | |||
+ | < | ||
+ | sudo aptitude install rng-tools | ||
+ | sudo vim / | ||
+ | </ | ||
+ | |||
+ | Dejar la siguiente linea: | ||
+ | |||
+ | HRNGDEVICE=/ | ||
+ | |||
+ | sudo / | ||
Al crear nuestra clave, se ha creado el siguiente directorio: | Al crear nuestra clave, se ha creado el siguiente directorio: | ||
Line 151: | Line 165: | ||
-rw------- 1 mi_usuario mi_usuario 1280 abr 22 12:55 trustdb.gpg | -rw------- 1 mi_usuario mi_usuario 1280 abr 22 12:55 trustdb.gpg | ||
</ | </ | ||
- | |||
==== Listar claves instaladas ==== | ==== Listar claves instaladas ==== | ||
Line 168: | Line 181: | ||
El id a retener es ' | El id a retener es ' | ||
+ | |||
+ | Para listar las claves privadas (en vez de pub pone sec) | ||
+ | gpg --list-secret-keys | ||
+ | |||
+ | sec | ||
+ | uid Nombre Apellisdo < | ||
+ | ssb | ||
+ | |||
Line 195: | Line 216: | ||
+ | ==== Revocar Clave del Servidor ==== | ||
+ | Si una clave vamos a dejar de usarla, hay que revocarla. | ||
+ | Para revocarla, tenemos que crear un certificado de revocación y luego subirlo al servidor. Para crear el certificado de revocación, | ||
+ | |||
+ | Vamos a revocar la antigua clave de 1024DSA porque hemos generado una nueva de 4096RSA | ||
+ | |||
+ | < | ||
+ | # gpg --list-keys | ||
+ | |||
+ | ----------------------------- | ||
+ | pub | ||
+ | uid Jose Legido < | ||
+ | sub | ||
+ | |||
+ | pub | ||
+ | uid Jose Legido < | ||
+ | sub | ||
+ | |||
+ | </ | ||
+ | < | ||
+ | # gpg --output revoke1024.asc --gen-revoke 5A988F96 | ||
+ | |||
+ | sec 1024D/ | ||
+ | Create a revocation certificate for this key? (y/N) y | ||
+ | Please select the reason for the revocation: | ||
+ | 0 = No reason specified | ||
+ | 1 = Key has been compromised | ||
+ | 2 = Key is superseded | ||
+ | 3 = Key is no longer used | ||
+ | Q = Cancel | ||
+ | (Probably you want to select 1 here) | ||
+ | Your decision? 3 | ||
+ | Enter an optional description; | ||
+ | > New Key F4AD9A55 | ||
+ | > | ||
+ | Reason for revocation: Key is no longer used | ||
+ | New Key F4AD9A55 | ||
+ | Is this okay? (y/N) y | ||
+ | |||
+ | You need a passphrase to unlock the secret key for | ||
+ | user: "Jose Legido < | ||
+ | 1024-bit DSA key, ID 5A988F96, created 2008-03-20 | ||
+ | |||
+ | ASCII armored output forced. | ||
+ | Revocation certificate created. | ||
+ | |||
+ | Please move it to a medium which you can hide away; if Mallory gets | ||
+ | access to this certificate he can use it to make your key unusable. | ||
+ | It is smart to print this certificate and store it away, just in case | ||
+ | your media become unreadable. | ||
+ | your machine might store the data and make it available to others! | ||
+ | </ | ||
+ | |||
+ | Ahora subimos el certificado de revocación para revocar la clave: | ||
+ | < | ||
+ | # gpg --import revoke1024.asc | ||
+ | gpg: key 5A988F96: "Jose Legido < | ||
+ | gpg: Total number processed: 1 | ||
+ | gpg: new key revocations: | ||
+ | gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model | ||
+ | gpg: depth: 0 valid: | ||
+ | </ | ||
+ | |||
+ | Al cabo de un rato, la clave aparece como revocada: | ||
+ | < | ||
+ | # gpg --search-keys jose@legido.com | ||
+ | gpg: searching for " | ||
+ | (1) Jose Legido < | ||
+ | 4096 bit RSA key F4AD9A55, created: 2014-09-15 | ||
+ | (2) Jose Legido < | ||
+ | 1024 bit DSA key 5A988F96, created: 2008-03-20 (revoked) | ||
+ | |||
+ | </ | ||
==== Descargar claves a servidor de claves ==== | ==== Descargar claves a servidor de claves ==== | ||
Line 238: | Line 332: | ||
+ | |||
+ | ==== Buscar claves ==== | ||
+ | No sé porqué, si buscas claves sin indicar servidor, da error: | ||
+ | # gpg --search-keys 5A988F96 | ||
+ | gpg: searching for " | ||
+ | gpg: keyserver timed out | ||
+ | gpg: keyserver search failed: keyserver error | ||
+ | |||
+ | Indicando otro servidor funciona, pero a veces también falla: | ||
+ | # gpg | ||
+ | gpg: searching for " | ||
+ | | ||
+ | (1) Jose Legido < | ||
+ | 1024 bit DSA key 5A988F96, created: 2008-03-20 | ||
+ | Keys 1-1 of 1 for " | ||
+ | Enter number(s), N)ext, or Q)uit > 1 | ||
+ | gpg: requesting key 5A988F96 from hkp server subkeys.pgp.net | ||
+ | gpg: key 5A988F96: "Jose Legido < | ||
+ | gpg: Total number processed: 1 | ||
+ | gpg: unchanged: 1 | ||
+ | |||
+ | Esto puede ser porque el puerto que usa es el 11371 y puede estar cerrado por algún proxy o firewall. Para probar si tenemos acceso hacemos: | ||
+ | # telnet pool.sks-keyservers.net 11371 | ||
+ | |||
+ | Para poder tener acceso al puerto, hacemos un tunneling con algún servidor que sepamos que si tiene acceso, por ejemplo, el pc de casa: | ||
+ | # ssh -L 11371: | ||
+ | Y una vez hecho el tunneling, nos conectamos al puerto local (de la L mayúsucula) que nos reenviará al servidor de casa y este al pool.sks-keyservers.net: | ||
+ | # gpg --keyserver localhost | ||
==== Importar claves desde un fichero ==== | ==== Importar claves desde un fichero ==== | ||
Line 354: | Line 476: | ||
Teclear ' | Teclear ' | ||
+ | |||
+ | |||
Line 362: | Line 486: | ||
Por si no tenemos instalado el gestor de claves en el correo, podemos copiar el mensaje en un fichero de texto y desencriptarlo. Copiamos el mensaje en el fichero encriptado.txt con las cabeceras: | Por si no tenemos instalado el gestor de claves en el correo, podemos copiar el mensaje en un fichero de texto y desencriptarlo. Copiamos el mensaje en el fichero encriptado.txt con las cabeceras: | ||
< | < | ||
- | -----BEGIN PGP MESSAGE----- | + | ----BEGIN PGP MESSAGE----- |
Charset: UTF-8 | Charset: UTF-8 | ||
Version: GnuPG v1.4.9 (Darwin) | Version: GnuPG v1.4.9 (Darwin) | ||
Line 372: | Line 496: | ||
leqyoh6+KHA7jSp8dFNgKKFncvIRKMpeuT7NVVNuQazmNEBz3IQy | leqyoh6+KHA7jSp8dFNgKKFncvIRKMpeuT7NVVNuQazmNEBz3IQy | ||
=tDU9 | =tDU9 | ||
- | -----END PGP MESSAGE----- | + | ----END PGP MESSAGE----- |
</ | </ | ||
Y con el siguiente comando lo desencripta en el fichero desencriptado.txt | Y con el siguiente comando lo desencripta en el fichero desencriptado.txt | ||
# gpg --output desencriptado.txt --decrypt encriptado.txt | # gpg --output desencriptado.txt --decrypt encriptado.txt | ||
+ | ==== Encriptar Fichero ==== | ||
+ | |||
+ | 1. Listar las claves instaladas para tenerlas a mano | ||
+ | |||
+ | gpg --list-keys | ||
+ | |||
+ | 2. Encriptar el archivo: | ||
+ | |||
+ | gpg --encrypt archivo.txt | ||
+ | |||
+ | 3. Introducir el identificador de la clave y pulsar ' | ||
+ | |||
+ | 4. Teclear ' | ||
+ | Se habra generado el archivo ' | ||
+ | 1 | ||
==== Programas adicionales ==== | ==== Programas adicionales ==== | ||
Line 444: | Line 583: | ||
gpg --list-keys | gpg --list-keys | ||
+ | |||
+ | |||
+ | ==== Exportar / importar clave privada ==== | ||
+ | |||
+ | **OJO** la clave privada no debe ser accesible por nadie más que su propietario | ||
+ | |||
+ | * Exportar | ||
+ | |||
+ | gpg --export-secret-key -a > clave_privada.key | ||
+ | |||
+ | * Importar | ||
+ | |||
+ | gpg --import clave_privada.key | ||
==== Otros ==== | ==== Otros ==== |
informatica/linux/claves_gpg.txt · Last modified: 2023/11/30 14:04 by jose