Outils pour utilisateurs

Outils du site


informatique:gpg2

La commande "gpg2"

La page de man de gpg2.

Générer une clé

$ gpg2 --gen-key

La commande va demander un nom, une adresse courriel et une phrase de passe.

Afficher les clés

$ gpg2 --list-keys

Exporter la clé publique

$ gpg2 --export --armor moi@simonlefort.be
-----BEGIN PGP PUBLIC KEY BLOCK-----
 
mQINBFS2fSsBEACujahRu6R+JppJ2RdD7OoRLwbWiuc3cewMqU48ZLPNl1ADIazf
kBaITiaC25itvzvoim4gcKA0pPX7lDmF/0NhNc4CHmnrbao4wpvhQ5kdsn7TGrVU
6RnUnsBSkvtclUncJ9soOlhi6AqqytUa5um2qg5IZxD0RITud9scphgpfC7gX2/I
7N2/Zbpq2khLDJirisz8YzUda2lwNLL1TtTOL5gUp39N0TWW8gQFEqYvQ3wcHlDe
hQ+Sn1ZUrBV5VTs+uA0nmxxwkueTl36GkvMkMRyG6bJB1/ZTuliLBUUPacijjgXb
niK7sa0cr7U/qYdmFaDdurGt96XPBQhQ/ozi8XiT7lVb6HfEUao77Zp8cdjpRp7u
dLdgsd2klr99DU0M2bVp18/Cmb3tkPx2/kzycSpCWb6Sh8fI4cUpF+GYmxzgyHaB
Uq2qK2ErUaKMpe0jiktXJHTEm4EVLcBzhwaLoSAfptH7GAhYxrlw2JUYYKh3vQo9
bN78gELNPrBBeY5JJlLPuA8PCrja8HcfhBtf1t0oO4pCqb4y8oqXlAhNYYNWVzzx
YFPtwQZqQxInNAShm7hZmz/ksTTq3tz9ESz+E3uVBs3AMd/eD+qfMK6WO7fDB2Sw
tWtwvG9moZS/PSfWLre+3q30+FchtU8fJkA3Gpo5c10xAO7UTDc1zadCkwARAQAB
tDhTaW1vbiBMZWZvcnQgKENsw6kgZGUgU2ltb24gTGVmb3J0KSA8bW9pQHNpbW9u
bGVmb3J0LmJlPokCOAQTAQIAIgUCVLZ9KwIbAwYLCQgHAwIGFQgCCQoLBBYCAwEC
HgECF4AACgkQlb+rGV1Oq2TmeA/+KJntienj4kpofHfnce0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oR/kMmmQLBMROFdP73Y/PilpWR
1cObt5hqu5i+WkSgnN6pwQGD3KSrdqUB89vlVQ068zErABEBAAGJAh8EGAECAAkF
AlS2fSsCGwwACgkQlb+rGV1Oq2QY3g/9H617dfyO/vrN+jaT+uJRyBePH57HkAqx
zsc/G4OgjhoCKfg9RD0I6MMWmMPA3LQ0+VrS8NCxiaGGXveX1oiuX3NSf0Q6PyMY
ZiYNQYigL5GOUnzR1weMPfeqny6LhQ8NH2W+F3+VM7MEpsv5us7rVF0RR++D0EGB
7NFmxHT8Mlsqbki26qAxqzNZKitXZPZKd+muRETre88wlyZmOlM6PVqJNPQtwHdh
8PMox3x2t9jyLCjVzGIg8vY1QypVSEWz5XkCKs+ocodrgaUUr3nE7u5JfblyiVu9
w8ps3DfA1hWg3zcLHjwB0zwLczcbJ9dvihcOS0GtHBMeSLuG8LsyxlxZuJ7GOZzz
yImsZagjxbHRUDvwvupbq7P3Dmla3bTGUkdYLa7Jrtt4grmk4qh7vpBBQ+gYrS8O
FjwWPsFRTieGF6LWJuxkLTONAvv/IA66EzhVIZTnaz6FBPWRlxAT6MMY9P2mH84c
CJo8yhEVlu2hIZXrjEO2bzHdAeDbFwwQMgmAs2y3caUl7D3E5TgR2+wAlUTTiStz
iYmhipUrrDYbmZTGE/wzfev7kfG7+4ZzsmRWTyeEPY+uVmROVO/qGMEYBAcRZPkD
wrMjzeez1LhRneD8sWwZywRM9MlVidbwR3CqZAqk61dlFPxDN7Z8OdoaTPQL8mZN
p1OdNY9RkkU=
=JzSo
-----END PGP PUBLIC KEY BLOCK-----

Importer la clé publique sur un serveur de clé

On peut utiliser par exemple pgp.mit.edu et simplement coller la clé qu'on a exporté juste au dessus. On peut aussi utiliser la ligne de commande pour faire la même chose :

$ gpg2 --keyserver pgp.mit.edu --send-keys  mon_id

Faire une recherche sur un serveur de clé

$ gpg2 --keyserver pgp.mit.edu --search-keys moi@simonlefort.be
gpg: data source: http://pgp.mit.edu:11371
(1)	keybase.io/simonlefort <simonlefort@keybase.io>
	Simon Lefort (Clé de Simon Lefort) <moi@simonlefort.be>
	  4096 bit RSA key 95BFAB195D4EAB64, créé : 2015-01-14
Keys 1-1 of 1 for "moi@simonlefort.be".  Entrez le ou les nombres, (S)uivant, ou (Q)uitter > 

Voir les préférences de la clé et les modifier

$ gpg2 --edit-key adresse@mail.com
(...)
gpg> showpref
(...)
     Cipher: AES256, AES192, AES, 3DES
     Digest: SHA256, SHA384, SHA512, SHA224, SHA1
     Compression: ZLIB, BZIP2, ZIP, Uncompressed
(...)
gpg> setpref SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
(...)
gpg> showpref
(...)
     Cipher: AES256, AES192, AES, CAST5, 3DES
     Digest: SHA512, SHA384, SHA256, SHA224, SHA1
     Compression: ZLIB, BZIP2, ZIP, Uncompressed
(...)
gpg> quit 
Save changes? (y/N) y

Supprimer un couple de clé privée / publique

$ gpg2 --list-keys
/home/simon/.gnupg/pubring.kbx
------------------------------
pub   rsa4096 2018-07-17 [SC] [expire : 2019-09-01]
      124A0E657EBD1B76246515289DE43634E0D82B55
uid          [  ultime ] Simon Lefort <mon@email.com>
sub   rsa4096 2018-07-17 [E] [expire : 2019-09-01]
 
 
$ gpg2 --delete-secret-keys 124A0E657EBD1B76246515289DE43634E0D82B55
gpg (GnuPG) 2.2.4; Copyright (C) 2017 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.
 
 
sec  rsa4096/9DE43634E0D82B55 2018-07-17 Simon Lefort <mon@email.com>
 
Faut-il supprimer cette clef du porte-clefs ? (o/N) o
C'est une clef secrète — faut-il vraiment la supprimer ? (o/N) o
 
 
$ gpg2 --delete-keys 124A0E657EBD1B76246515289DE43634E0D82B55
gpg (GnuPG) 2.2.4; Copyright (C) 2017 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.
 
pub  rsa4096/9DE43634E0D82B55 2018-07-17 Simon Lefort <mon@email.com>
 
Faut-il supprimer cette clef du porte-clefs ? (o/N) o
 
 
$ gpg2 --list-keys
gpg: vérification de la base de confiance
gpg: aucune clef de confiance ultime n'a été trouvée

Sources

informatique/gpg2.txt · Dernière modification : 2020/08/09 13:03 de 127.0.0.1