tech:gpg_-_utilisation_basique_-_exemples
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:gpg_-_utilisation_basique_-_exemples [2025/09/27 16:35] – Jean-Baptiste | tech:gpg_-_utilisation_basique_-_exemples [2026/06/29 15:32] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # GPG - Utilisation basique - exemples | ||
| + | |||
| + | Documentation : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Procédure simple chiffrer un message ou un fichier : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * [Guide d’autodéfense numérique](https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Recommandations : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Autre : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * [GNU Privacy Assistant (GPA)](https:// | ||
| + | |||
| + | Voir : | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | |||
| + | ## Importer une clef | ||
| + | |||
| + | Importer une clef localement | ||
| + | ~~~bash | ||
| + | gpg --import correspondant.pgp | ||
| + | ~~~ | ||
| + | |||
| + | Importer une clef via Internet | ||
| + | |||
| + | Tscoks et Tor doivent être installés et configurés | ||
| + | Voir [[tor_tsocks]] | ||
| + | |||
| + | ~~~bash | ||
| + | tsocks gpg --recv-keys 5AA19646 | ||
| + | ~~~ | ||
| + | |||
| + | ## Utilisation basique - exemples | ||
| + | |||
| + | Exemple de chiffrement | ||
| + | noté `-R` à la place du `-r` pour caché qui est le destinataire du fichier | ||
| + | ~~~bash | ||
| + | gpg -R jean@acme.fr --throw-keyids --encrypt data.dat | ||
| + | ~~~ | ||
| + | |||
| + | Ici nous signons le fichier `data.dat.gpg` (crée la commande précédente) | ||
| + | ~~~bash | ||
| + | gpg --detach-sign data.dat.gpg | ||
| + | ~~~ | ||
| + | |||
| + | On vérifie la signature | ||
| + | ~~~bash | ||
| + | gpg --verify data.dat.gpg.sig data.dat.gpg | ||
| + | ~~~ | ||
| + | |||
| + | Si la signature est bonne, on déchiffre | ||
| + | ~~~bash | ||
| + | gpg --decrypt data.dat.gpg | ||
| + | ~~~ | ||
| + | |||
| + | --------- | ||
| + | |||
| + | ### Exemple en ligne de commande | ||
| + | |||
| + | #### Signé et chiffré | ||
| + | ~~~bash | ||
| + | gpg --sign plop.txt | ||
| + | gpg --encrypt -R jean@acme.fr plop.txt.gpg | ||
| + | mv plop.txt.gpg.gpg plop | ||
| + | ~~~ | ||
| + | |||
| + | On envoie notre fichier plop | ||
| + | |||
| + | #### Déchiffrement et vérification signature | ||
| + | ~~~ | ||
| + | $ gpg plop | ||
| + | gpg: plop : suffixe inconnu | ||
| + | Entrez le nouveau nom de fichier [plop.txt.gpg]: | ||
| + | ~~~ | ||
| + | |||
| + | Faire **[Entrée]** | ||
| + | ~~~bash | ||
| + | gpg plop.txt.gpg && echo OK | ||
| + | ~~~ | ||
| + | |||
| + | Nous retrouvons le fichier `plop.txt` | ||
| + | |||
| + | ## Avancée | ||
| + | |||
| + | ## Commandes passives | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | gpg --with-fingerprint --list-secret-key | ||
| + | gpg --list-keys your_email@address.com | ||
| + | |||
| + | echo ' | ||
| + | ~~~ | ||
| + | |||
| + | Avoir plus d' | ||
| + | ~~~bash | ||
| + | gpg --list-packets public-key.asc | ||
| + | ~~~ | ||
| + | |||
| + | Avoir des informations sur un fichier chiffré | ||
| + | ~~~bash | ||
| + | gpg report.txt.gpg | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres conversions formats | ||
| + | |||
| + | Uuencode / uudecode | ||
| + | Pour encoder, il suffit de taper : | ||
| + | |||
| + | ~~~bash | ||
| + | gpg -a --store chemin/ | ||
| + | ~~~ | ||
| + | (Cela produira en sortie chemin/ | ||
| + | |||
| + | Pour décoder, c’est encore plus simple: | ||
| + | ~~~bash | ||
| + | gpg chemin/ | ||
| + | ~~~ | ||
| + | |||
| + | convert .asc to .gpg (and eventually vice-versa) | ||
| + | |||
| + | ~~~bash | ||
| + | gpg --dearmor the-asc-file.asc | ||
| + | ~~~ | ||
| + | |||
| + | will convert from .asc to .gpg | ||
| + | ~~~bash | ||
| + | cat the-gpg-file.gpg | gpg --enarmor | sed ' | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | printf ' | ||
| + | ~~~ | ||
| + | |||
| + | |||
