Generation of a gpg key in Ubuntu 16

Generation of your gpg key

$ gpg --gen-key

If you need to generate random entropy

$  apt-get install rng-tools
$  rngd -f -r /dev/urandom
$  cp -a /dev/urandom /dev/random

The output is something like this

gpg: clave B3AEFF89 marcada como de confianza absoluta
claves p├║blica y secreta creadas y firmadas.

gpg: comprobando base de datos de confianza
gpg: 3 dudosa(s) necesaria(s), 1 completa(s) necesaria(s),
modelo de confianza PGP
gpg: nivel: 0  validez:   1  firmada:   0  confianza: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/B3AEFF89 2017-04-26
      Huella de clave = 7343 EE4F 867C 373E 1D9A  DE01 B04C 1105 B3AE FC14
uid                  Hector Perez <>
sub   2048R/84FD55D2 2017-04-26

From this message you have to extract your gpg key, in this case is B3AEFF89. Next, go to and search your key 0xB3AEFF89 (The two first characters 0x must be added) Next, you will find your key there. After, copy and save the content of your key in a file, let's say keyfile.txt

$ sudo apt-key add keyfile.txt

That is all!

Another useful commands are:

To list your gpg keys

$ sudo apt-key list

To delete a gpg key B3AEFF89

$ sudo apt-key del B3AEFF89