Table des matières
- 2026:
- 2025:
13 billet(s) pour novembre 2026
| Réseaux - protocole QUIC mieux que TCP | 2026/11/17 21:26 | Jean-Baptiste |
| Notes conversion JSON YAML | 2026/11/13 11:16 | Jean-Baptiste |
| Git commit perdu | 2026/11/12 18:16 | Jean-Baptiste |
| Notes mojo lang | 2026/11/11 20:34 | Jean-Baptiste |
| Notes rust lang compilation | 2026/11/11 18:35 | Jean-Baptiste |
| Mémoire VSIZE VMSIZE SEGV lang C | 2026/11/11 15:59 | Jean-Baptiste |
| Ansible-navigator utilisation de ansible-vault | 2026/11/06 11:33 | Jean-Baptiste |
| Err Ansible - Module result deserialization failed No start of json char found | 2026/11/06 09:09 | Jean-Baptiste |
| Script Python conversion JSON vers CSV | 2026/11/06 08:14 | Jean-Baptiste |
| Filter Incoming IPv4 Packets Containing IP Options - cve-2026-98432 mitigation - Kernel TCP Use-After-Free | 2026/11/04 21:04 | Jean-Baptiste |
| Notes ZFS | 2026/11/03 18:04 | Jean-Baptiste |
| Diff image container | 2026/11/03 16:30 | Jean-Baptiste |
| Notes processus multi-thread | 2026/11/03 10:59 | Jean-Baptiste |
GPG - signer une clef - key signing party
Signer la clef de quelqu'un
Voir :
Signer la clef de qqun 1
Importation de la clef en local
# Vérifier l'emprunte avant de l'importer gpg --with-fingerprint key.asc # Puis si OK gpg --import key.asc
Ou importation de la clef depuis internet
gpg --recv-key '<fingerprint>'
Vérifier
gpg -v --fingerprint '<fingerpring>'
Si ok signez localement la clef
gpg --lsign-key '<fingerprint>'
Pour changer la confiance a accorder à la personne (optionnel)
gpg --edit-key '<fingerprint>'
3 est un bon choix
Ou pour la signer et l'envoyer sur le serveur de clefs
#gpg --sign-key --ask-cert-level '<fingerprint>' gpg --sign-key '<fingerprint>' gpg --send-keys --keyserver '<fingerprint>'
Donnez votre signature à la personne concernée
gpg --output ~/signed.key --export --armor email@example.com
La personne devra faire
gpg --import ~/signed.key
Signer la clef de qqun 2
gpg --ask-cert-level --sign-key jean@acme.fr
Exporter la signature
gpg -a --export jean@acme.fr > jean_at_acme.fr.asc gpg --sign --encrypt -r jean@acme.fr jean_at_acme.fr.asc
Recevoir une signature
gpg --decrypt jean_at_acme.fr.asc.gpg gpg --import jean_at_acme.fr.asc
Vérifier puis exporter la signature
gpg --list-sigs jean@acme.fr gpg --send-keys <KeyID>
GPG - Script - batch - auto encrypt
Voir aussi :
Par défaut GPG utilise le dossier « .gnupg » dans le HOMEDIR de l'utilisateur. Il contient notamment la configuration, le trousseau de clefs, le trust database etc…
Or notre besoin actuel est juste de pouvoir chiffrer un fichier avec une clef publique déterminée. Je propose une approche “stateless” où le trousseau de clefs serait créé avant chaque chiffrement et détruit à la fin.
Par exemple pour chiffrer “secret_plan_to_rule_the_world.txt” avec la clef publique de Bob :
bash gpg-auto-encrypt.sh -k bob.pub.asc -i secret_plan_to_rule_the_world.txt -o encrypted-data.txt.gpg
Le fichier “encrypted-data.txt.gpg” a été généré et peut être envoyé. Seul Bob pourra le déchiffrer.
En cas de changement de clef, il suffit de remplacer le fichier “bob.pub.asc”
Il manque cruellement la vérification de Signature \ Sans signature rien de garantie que le fichier chiffré n’a été altéré volontairement ou pour des causes techniques.\ Sans signature vous pouvez faire confiance sur le fait que seul Bob pourra déchiffré le fichier (à condition d’être certain de la clef de Bob et que Bob ai bien protégé sa clef privée) \ Mais Bob ne peut pas avoir confiance en votre fichier.
gpg-auto-encrypt.sh
#! /bin/bash set -euo pipefail export LC_ALL=C SCRIPT_NAME="$(basename "$0")" install -d "${HOME}/tmp/" GNUPGHOME="$(mktemp -d -p "${HOME}/tmp/" --suffix=_"${SCRIPT_NAME%%.*}")" trap 'rm -rf "$GNUPGHOME"' EXIT gpg_import() { PUBKEY_ID=$(gpg --batch --import "${PUBKEY_FILE}" 2>&1 | awk '/^gpg: key / {gsub(":", "") ; print $3 ;}') } gpg_encrypt() { gpg --batch --trust-model always --output "$OUTPUT_FILE" -r "${PUBKEY_ID}" --encrypt "$DATA_FILE" } main() { gpg_import gpg_encrypt } usage() { cat <<-EOF Usage: $0 -k KEY_FILE -i INPUT_FILE -o OUTPUT_FILE Mandatory arguments: -k FILE Public key file. -i FILE File to encrypt. -o FILE Encrypted file to write. Example : $0 -k bob.pub.asc -i secret_plan_to_rule_the_world.txt -o encrypted-data.txt.gpg EOF } ARGS_COUNT="$#" while [ "${1-}" != "" ]; do case $1 in -k) shift PUBKEY_FILE=$1 ;; -i) shift DATA_FILE=$1 ;; -o) shift OUTPUT_FILE=$1 ;; -h | --help) usage exit 0 ;; --) # End of all options shift break ;; -*) echo "SCRIPT_NAME: invalid option" >&2 echo "Try '$SCRIPT_NAME --help' for more information." >&2 exit 1 ;; *) usage ;; esac shift done if [ "$ARGS_COUNT" -lt 6 ]; then usage exit 1 fi main
GPG - Renouvellement de clefs
Revoke
Revoquer ca clef https://www.gnupg.org/gph/en/manual/c235.html
gpg --gen-revoke 50D12DE07663C664 --output ~/revocation.crt chmod 600 ~/revocation.crt
gpg --import ~/.gnupg/email@domain.tld.rev.asc gpg --export -a your_keyid >mykey.asc gpg --keyserver subkeys.pgp.net --send 50D12DE07663C664 gpg --keyserver pgp.mit.edu --send-keys mykey
revkey revsig save
gpg --import ~/.gnupg/email@domain.tld.public_key.asc ~/.gnupg/email@domain.tld.private_key.asc gpg --edit-key email@domain.tld
Expired
Que faire quand la clef a expirée
https://makandracards.com/makandra-orga/13644-what-to-do-when-your-gpg-pgp-key-expires
gpg --edit-key 0x12345678 gpg> expire ... gpg> save
gpg --edit-key 0x12345678 gpg> key 1 gpg> expire ... gpg> key 1 gpg> key 2 gpg> expire ... gpg> save
Renew primary key
GPG - recovering lost gpg public keys from your yubikey
Source : https://www.nicksherlock.com/2021/08/recovering-lost-gpg-public-keys-from-your-yubikey/
$ gpg --card-status
Reader ...........: Nitrokey Nitrokey Pro (00000000000000000000BD62) 00 00
Application ID ...: D27600012401030400050000BD620000
Application type .: OpenPGP
Version ..........: 3.4
Manufacturer .....: ZeitControl
Serial number ....: 0000BD62
Name of cardholder: [not set]
Language prefs ...: de
Salutation .......:
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: brainpoolP512r1 brainpoolP512r1 brainpoolP512r1
Max. PIN lengths .: 64 64 64
PIN retry counter : 3 0 3
Signature counter : 0
KDF setting ......: off
Signature key ....: 5A79 88CB 3667 6795 A817 0DB7 CBBD AA0F 4B7C 7DD7
created ....: 2023-02-26 14:04:38
Encryption key....: 8695 C0E7 6ABC 2FFF F7CC 7D71 F8CE 04C4 D381 8C66
created ....: 2023-02-26 14:07:32
Authentication key: 1D9D 57AF C804 3C8E 1AA8 82ED 7571 DCC2 1DE7 4064
created ....: 2023-02-26 14:09:20
General key info..: [none]
Les champs qui nous intéressent :
Signature key ....: 5A79 88CB 3667 6795 A817 0DB7 CBBD AA0F 4B7C 7DD7
created ....: 2023-02-26 14:04:38
Encryption key....: 8695 C0E7 6ABC 2FFF F7CC 7D71 F8CE 04C4 D381 8C66
created ....: 2023-02-26 14:07:32
Authentication key: 1D9D 57AF C804 3C8E 1AA8 82ED 7571 DCC2 1DE7 4064
created ....: 2023-02-26 14:09:20
2023-02-26 14:04:38 va devenir 20230226T140438!
Création de la clef primaire (sign)
$ gpg --faked-system-time "20230226T140438!" --expert --full-generate-key
gpg: WARNING: running with faked system time: 2023-02-26 14:04:38
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)
(7) DSA (set your own capabilities)
(8) RSA (set your own capabilities)
(9) ECC and ECC
(10) ECC (sign only)
(11) ECC (set your own capabilities)
(13) Existing key
(14) Existing key from card
Your selection? 14
Serial number of the card: D27600012401030400050000BD620000
Available keys:
(1) 3F5417680639FCEF05C54803B408B83BA496E964 OPENPGP.1 brainpoolP512r1 (cert,sign)
(2) DC81057888D07B12268226B9F136013C4D32566D OPENPGP.2 brainpoolP512r1 (encr)
(3) F66AA9329AEA6F09D69DD852BF8233DE68119AF5 OPENPGP.3 brainpoolP512r1 (sign,auth)
Your selection? 1
Possible actions for a ECDSA/EdDSA key: Sign Certify
Current allowed actions: Sign Certify
(S) Toggle the sign capability
(Q) Finished
Your selection? q
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) 1y
Key expires at Mon 26 Feb 2024 03:04:38 PM CET
Is this correct? (y/N) y
GnuPG needs to construct a user ID to identify your key.
Real name: Bob MARLEY
Email address: bmarley@acme.fr
Comment:
You selected this USER-ID:
"Bob MARLEY <bmarley@acme.fr>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
gpg: directory '/home/jibe/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/jibe/.gnupg/openpgp-revocs.d/5A7988CB36676795A8170DB7CBBDAA0F4B7C7DD7.rev'
public and secret key created and signed.
pub brainpoolP512r1 2023-02-26 [SC] [expires: 2024-02-26]
5A79 88CB 3667 6795 A817 0DB7 CBBD AA0F 4B7C 7DD7
uid Bob MARLEY <bmarley@acme.fr>
Création des clefs secondaires
La seconde clef
$ gpg --faked-system-time "20230226T140732!" --expert --edit-key bmarley
gpg: WARNING: running with faked system time: 2023-02-26 14:07:32
Secret key is available.
gpg: checking the trustdb
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2024-02-26
sec brainpoolP512r1/CBBDAA0F4B7C7DD7
created: 2023-02-26 expires: 2024-02-26 usage: SC
card-no: 0005 0000BD62
trust: ultimate validity: ultimate
[ultimate] (1). Bob MARLEY <bmarley@acme.fr>
gpg> addkey
Secret parts of primary key are stored on-card.
Please select what kind of key you want:
(3) DSA (sign only)
(4) RSA (sign only)
(5) Elgamal (encrypt only)
(6) RSA (encrypt only)
(7) DSA (set your own capabilities)
(8) RSA (set your own capabilities)
(10) ECC (sign only)
(11) ECC (set your own capabilities)
(12) ECC (encrypt only)
(13) Existing key
(14) Existing key from card
Your selection? 14
Serial number of the card: D27600012401030400050000BD620000
Available keys:
(1) 3F5417680639FCEF05C54803B408B83BA496E964 OPENPGP.1 brainpoolP512r1 (cert,sign)
(2) DC81057888D07B12268226B9F136013C4D32566D OPENPGP.2 brainpoolP512r1 (encr)
(3) F66AA9329AEA6F09D69DD852BF8233DE68119AF5 OPENPGP.3 brainpoolP512r1 (sign,auth)
Your selection? 2
Possible actions for a ECDH key: Encrypt
Current allowed actions: Encrypt
(E) Toggle the encrypt capability
(Q) Finished
Your selection? q
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) 1y
Key expires at Mon 26 Feb 2024 03:07:32 PM CET
Is this correct? (y/N) y
Really create? (y/N) y
sec brainpoolP512r1/CBBDAA0F4B7C7DD7
created: 2023-02-26 expires: 2024-02-26 usage: SC
card-no: 0005 0000BD62
trust: ultimate validity: ultimate
ssb brainpoolP512r1/F8CE04C4D3818C66
created: 2023-02-26 expires: 2024-02-26 usage: E
card-no: 0005 0000BD62
[ultimate] (1). Bob MARLEY <bmarley@acme.fr>
gpg> quit
Save changes? (y/N) y
La troisieme clef
$ gpg --faked-system-time "20230226T140920!" --expert --edit-key bmarley
gpg: WARNING: running with faked system time: 2023-02-26 14:09:20
Secret key is available.
sec brainpoolP512r1/CBBDAA0F4B7C7DD7
created: 2023-02-26 expires: 2024-02-26 usage: SC
card-no: 0005 0000BD62
trust: ultimate validity: ultimate
ssb brainpoolP512r1/F8CE04C4D3818C66
created: 2023-02-26 expires: 2024-02-26 usage: E
card-no: 0005 0000BD62
[ultimate] (1). Bob MARLEY <bmarley@belaris.fr>
gpg> addkey
Secret parts of primary key are stored on-card.
Please select what kind of key you want:
(3) DSA (sign only)
(4) RSA (sign only)
(5) Elgamal (encrypt only)
(6) RSA (encrypt only)
(7) DSA (set your own capabilities)
(8) RSA (set your own capabilities)
(10) ECC (sign only)
(11) ECC (set your own capabilities)
(12) ECC (encrypt only)
(13) Existing key
(14) Existing key from card
Your selection? 14
Serial number of the card: D27600012401030400050000BD620000
Available keys:
(1) 3F5417680639FCEF05C54803B408B83BA496E964 OPENPGP.1 brainpoolP512r1 (cert,sign)
(2) DC81057888D07B12268226B9F136013C4D32566D OPENPGP.2 brainpoolP512r1 (encr)
(3) F66AA9329AEA6F09D69DD852BF8233DE68119AF5 OPENPGP.3 brainpoolP512r1 (sign,auth)
Your selection? 3
Possible actions for a ECDSA/EdDSA key: Sign Authenticate
Current allowed actions: Sign Authenticate
(S) Toggle the sign capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? s
Possible actions for a ECDSA/EdDSA key: Sign Authenticate
Current allowed actions: Authenticate
(S) Toggle the sign capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? q
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) 1y
Key expires at Mon 26 Feb 2024 03:09:20 PM CET
Is this correct? (y/N) y
Really create? (y/N) y
sec brainpoolP512r1/CBBDAA0F4B7C7DD7
created: 2023-02-26 expires: 2024-02-26 usage: SC
card-no: 0005 0000BD62
trust: ultimate validity: ultimate
ssb brainpoolP512r1/F8CE04C4D3818C66
created: 2023-02-26 expires: 2024-02-26 usage: E
card-no: 0005 0000BD62
ssb brainpoolP512r1/7571DCC21DE74064
created: 2023-02-26 expires: 2024-02-26 usage: A
card-no: 0005 0000BD62
[ultimate] (1). Bob MARLEY <bmarley@belaris.fr>
gpg> quit
Save changes? (y/N) y
GPG - Publier sa clef sur un serveur
Voir aussi :
Serveur de clefs / keyservers SKS WKD - hkp / hkps:
Voir :
Remplacer SKS par WKD :
Serveur de clefs
gpg --refresh-keys gpg --keyserver key_server --refresh-keys
gpg --keyserver pgp.mit.edu --search-key
Publier
https://wiki.debian.org/fr/Subkeys
# gpg --send-keys --keyserver keyring.debian.org KeyID # gpg --send-keys --keyserver subkeys.pgp.net KeyID gpg --keyserver keyserver.ubuntu.com --send-key KeyID #gpg --keyserver hkps://keys.openpgp.org --send-key KeyID gpg --export KeyID | curl -T - https://keys.openpgp.org
Voir : https://keys.openpgp.org/about
Publier une clef que vous signé
A vérifier
tsocks gpg --send-keys 5AA19646
Tor
Rafraîchissez vos clés l’une après l’autre. Parcimonie est un démon qui rafraîchit lentement votre trousseau de clés à partir d’un serveur de clés en passant par Tor. Il utilise un délai aléatoire
sudo apt-get install parcimonie
Penser à mettre à jour les clefs GPG via Tor grâce à parcimonie
http://genma.free.fr/?Mise-a-jour-des-clefs-GPG-via-Tor
You should not use gpg --refresh-keys or the refresh keys menu item on your email client because you disclose to anyone listening, and the keyserver operator, the whole set of keys that you are interested in refreshing.
