Forum Francophone de Puppy/Toutou Linux => Internet => Discussion initiée par: Rantanplan le Jeudi 23 Avril 2026, 16:28:16
Titre: mutt et GnuPG
Publié par: Rantanplan le Jeudi 23 Avril 2026, 16:28:16
Bonjour les addictos à Toutou et autres Puppy Linux,
Liminaire Dans cet article, nous allons voir comment paramétrer mutt afin de l'utiliser avec GnuPG.
S'agissant de mutt, je suggère de lire cet article de présentation (https://augras.eu/puppy_forum/index.php?topic=331.0).
S'agissant de GnuPG, je propose de parcourir cet autre article (https://augras.eu/puppy_forum/index.php?topic=186.0).
S'agissant de la phrase secrète, peut-être trouverez des réponses et un outil dans ce billet (https://augras.eu/puppy_forum/index.php?topic=192.0), mais le script demeure facultatif. Une phrase secrète peut être créée par différents moyens et méthodes.
Et, enfin, je vous invite à cliquer sur ce lien (https://emailselfdefense.fsf.org/fr/index.html) qui explique tout (ou presque) sur l'usage de sa messagerie avec GnuPG (l'auteur n'a aucun intérêt avec les auteurs de ce site très bien conçu).
Création de son trousseau de clés privée et publique Première opération qui doit être OBLIGATOIREMENT réalisée. GnuPG doit être installé (l'auteur utilise GnuPG version legacy 1.4.23). Puis, ouvrez un terminal pour entrer la commande suivante :
Validez avec <Entrée> et laissez-vous guider. Si vous n'utilisez pas de pupsave, pensez à sauvegarder votre trousseau (voir dans /root/.gnupg/). Relevez les identifiants de clés (8 caractères alphanumériques, voire héxadécimaux), ils seront utiles plus loin. Et, conformez-vous aux recommandations émises par https://emailselfdefense.fsf.org (https://emailselfdefense.fsf.org) Attention ! Ne partagez JAMAIS votre clé PRIVÉE, car comme son nom l'indique elle est PRIVÉE.
Paramétrer mutt Votre humble serviteur, selon la formule consacrée, utilise la version '2.2.14' avec Toutou Linux Slaxen 6.0. Ci-dessous, un exemple de fichier muttrc complété pour GnuPG (stocké sous /root/.mutt/) :
set ssl_starttls = no # peut être commentée si mutt ne se lance pas set ssl_force_tls = yes set from = 'quidam@fai.ext' # à mettre à jour avec votre adresse mail complète set folder=//imap.fai.ext # remplacer fai.ext (i.e., par wanadoo.fr) set include=yes set realname=`echo $from | cut -d"@" -f1` set mailcap_path=/root/.mutt/.mailcap # IMAP paramètres set imap_user = $from set imap_pass = # SMTP paramètres set smtp_url = "smtps://${from}@smtp.fai.ext" # remplacer fai.ext (i.e., par wanadoo.fr) set smtp_pass = "$imap_pass" set signature = "/root/.mutt/signature" source /root/.mutt/adresses # Dossier distants set folder = "imaps://imap.fai.ext" # remplacer fai.ext (i.e., par wanadoo.fr) set spoolfile = "+INBOX" set postponed = "+INBOX/Drafts" set record = "+INBOX/Sent" set trash = "+INBOX/Trash" set editor = "leafpad" # Barre latérale set sidebar_width=12 set sidebar_visible=yes set sidebar_delim_chars='|' set sidebar_sort_method=unsorted # ctrl-n, ctrl-p pour sélectionner le dossier suivant, précédent # ctrl-o pour ouvrir le dossier sélectionné bind index,pager \CP sidebar-prev bind index,pager \CN sidebar-next bind index,pager \CO sidebar-open # Boîtes à lettres mailboxes -label "Arrivé" $spoolfile \ -label "Envoyé" $record \ -label "Brouillons" $postponed \ -label "Lazaret" "+INBOX/QUARANTAINE" \ -label "Corbeille" $trash # Gestion réponse, transfert set fast_reply = yes set attribution = "Le %d, %n a écrit :" set forward_quote = yes set forward_attribution_intro = "----- Message transféré de %f -----" set forward_attribution_trailer = "----- Fin du message transféré -----" set date_format="%A %d %B %Y à %H:%M:%S" # ne pas utiliser gpgme unset crypt_use_gpgme source /root/.mutt/gpg.rc source /root/.mutt/smime.rc # ne pas utiliser gpg_agent uniquement si version gpg < 2.1.0, sinon commenter ou supprimer cette ligne et la suivante unset pgp_use_gpg_agent
Rendez-vous aux lignes 40 et 46 pour supprimer le caractère # et l'espace qui suit afin de les décommenter. Puis, remplacer les chaîne '12345678' et '87654321' (conservez les deux premiers caractères '0x') par l'identifiant de chacune des clés (s'il y a un seul identifiant, recopiez celui de la ligne 40 à la ligne 46). Sauvegardez et fermez l'éditeur de textes.
# -*-muttrc-*- # # Command formats for gpg. # # Some of the older commented-out versions of the commands use gpg-2comp from: # http://70t.de/download/gpg-2comp.tar.gz # # %p The empty string when no passphrase is needed, # the string "PGPPASSFD=0" if one is needed. # # This is mostly used in conditional % sequences. # # %f Most PGP commands operate on a single file or a file # containing a message. %f expands to this file's name. # # %s When verifying signatures, there is another temporary file # containing the detached signature. %s expands to this # file's name. # # %a In "signing" contexts, this expands to the value of the # configuration variable $pgp_sign_as, if set, otherwise # $pgp_default_key. You probably need to # use this within a conditional % sequence. # # %r In many contexts, mutt passes key IDs to pgp. %r expands to # a list of key IDs.
# Section A: Key Management
# The default key for encryption (used by $pgp_self_encrypt and # $postpone_encrypt). # # It will also be used for signing unless $pgp_sign_as is set to a # key. # # Unless your key does not have encryption capability, uncomment this # line and replace the keyid with your own. # set pgp_default_key="0x12345678"
# If you have a separate signing key, or your key _only_ has signing # capability, uncomment this line and replace the keyid with your # signing keyid. # set pgp_sign_as="0x87654321"
# Section B: Commands
# Note that we explicitly set the comment armor header since GnuPG, when used # in some localiaztion environments, generates 8bit data in that header, thereby # breaking PGP/MIME.
# import a key into the public key ring set pgp_import_command="gpg --no-verbose --import %f"
# export a key from the public key ring set pgp_export_command="gpg --no-verbose --export --armor %r"
# verify a key set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r"
# read in the public key ring # note: the second --with-fingerprint adds fingerprints to subkeys set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-keys %r"
# read in the secret key ring # note: the second --with-fingerprint adds fingerprints to subkeys set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-secret-keys %r"
# fetch keys # set pgp_getkeys_command="pkspxycwrap %r"
# pattern for good signature - may need to be adapted to locale!
# set pgp_good_sign="^gpgv?: Good signature from "
# OK, here's a version which uses gnupg's message catalog: # set pgp_good_sign="`gettext -d gnupg -s 'Good signature from "' | tr -d '"'`"
# This version uses --status-fd messages set pgp_good_sign="^\\[GNUPG:\\] GOODSIG"
# pattern to verify a decryption occurred # This is now deprecated by pgp_check_gpg_decrypt_status_fd: # set pgp_decryption_okay="^\\[GNUPG:\\] DECRYPTION_OKAY" set pgp_check_gpg_decrypt_status_fd
Puis, encore et toujours dans le terminal, saisissez maintenant :
Rendez-vous aux lignes 37 et 43 pour supprimer le caractère # et l'espace qui suit afin de les décommenter. Puis, remplacer les chaînes '12345678' et '87654321' (conservez les deux derniers caractères '.0') par l'identifiant de chacune des clés (s'il y a un seul identifiant, recopiez celui de la ligne 37 à la ligne 43). Sauvegardez et fermez l'éditeur de textes.
# -*-muttrc-*- ## The following options are only available if you have ## compiled in S/MIME support
# If you compiled mutt with support for both PGP and S/MIME, PGP # will be the default method unless the following option is set # set smime_is_default
# Uncomment this if you don't want to set labels for certificates you add. # unset smime_ask_cert_label
# Passphrase expiration # set smime_timeout=300
# Global crypto options -- these affect PGP operations as well. # set crypt_autosign = yes # set crypt_replyencrypt = yes # set crypt_replysign = yes # set crypt_replysignencrypted = yes # set crypt_verify_sig = yes
# Section A: Key Management
# The default keyfile for encryption (used by $smime_self_encrypt and # $postpone_encrypt). # # It will also be used for decryption unless # $smime_decrypt_use_default_key is unset. # # It will additionally be used for signing unless $smime_sign_as is # set to a key. # # Unless your key does not have encryption capability, uncomment this # line and replace the keyid with your own. # set smime_default_key="12345678.0"
# If you have a separate signing key, or your key _only_ has signing # capability, uncomment this line and replace the keyid with your # signing keyid. # set smime_sign_as="87654321.0"
# Uncomment to make mutt ask what key to use when trying to decrypt a message. # It will use the default key above (if that was set) else. # unset smime_decrypt_use_default_key
# Path to a file or directory with trusted certificates set smime_ca_location="~/.smime/ca-bundle.crt"
# Path to where all known certificates go. (must exist!) set smime_certificates="~/.smime/certificates"
# Path to where all private keys go. (must exist!) set smime_keys="~/.smime/keys"
# These are used to extract a certificate from a message. # First generate a PKCS#7 structure from the message. set smime_pk7out_command="openssl smime -verify -in %f -noverify -pk7out"
# Extract the included certificate(s) from a PKCS#7 structure. set smime_get_cert_command="openssl pkcs7 -print_certs -in %f"
# Extract the signer's certificate only from a S/MIME signature (sender verification) set smime_get_signer_cert_command="openssl smime -verify -in %f -noverify -signer %c -out /dev/null"
# This is used to get the email address the certificate was issued to. set smime_get_cert_email_command="openssl x509 -in %f -noout -email"
# Add a certificate to the database using smime_keys. set smime_import_cert_command="smime_keys add_cert %f"
# Section B: Outgoing messages
# Algorithm to use for encryption. # valid choices are aes128, aes192, aes256, rc2-40, rc2-64, rc2-128, des, des3 set smime_encrypt_with="aes256"
# Encrypt a message. Input file is a MIME entity. set smime_encrypt_command="openssl cms -encrypt -%a -outform DER -in %f %c"
# Algorithm for the signature message digest. # Valid choices are md5, sha1, sha224, sha256, sha384, sha512. set smime_sign_digest_alg="sha256"
# Decrypt a message. Output is a MIME entity. set smime_decrypt_command="openssl cms -decrypt -passin stdin -inform DER -in %f -inkey %k -recip %c"
# Verify a signature of type multipart/signed set smime_verify_command="openssl smime -verify -inform DER -in %s %C -content %f"
# Verify a signature of type application/x-pkcs7-mime set smime_verify_opaque_command="\ openssl smime -verify -inform DER -in %s %C || \ openssl smime -verify -inform DER -in %s -noverify 2>/dev/null"
# application/pkcs7-mime ".p7m" messages should have a smime-type # parameter to tell Mutt whether it's signed or encrypted data. # # If the parameter is missing, Mutt by default assumes it's SignedData. # This can be used to change Mutt's assumption to EnvelopedData (encrypted). # # set smime_pkcs7_default_smime_type="enveloped"
# Section D: Alternatives
# Sign. If you wish to NOT include the certificate your CA used in signing # your public key, use this command instead. # set smime_sign_command="openssl smime -sign -md %d -signer %c -inkey %k -passin stdin -in %f -outform DER" # # In order to verify the signature only and skip checking the certificate chain: # # set smime_verify_command="openssl smime -verify -inform DER -in %s -content %f -noverify" # set smime_verify_opaque_command="openssl smime -verify -inform DER -in %s -noverify" #
Encore une fois, si vous n'utilisez pas de pupsave, pensez à enregistrer '/root/.mutt'.
Voilà, mutt est dorénavant configuré pour GnuPG.
L'auteur a testé avec une clé réservée à la signature. Voici le message envoyé à joe.dalton depuis mutt :
Citer
Afficher (cliquer pour afficher/cacher)
Date: Thu, 23 Apr 2026 10:23:16 +0200 From: rantanplan@daisy.town To: joe.dalton@dalton.city Subject: test signature
[-- La sortie PGP suit (heure courante : jeu. 23 avril 2026 10:23:33 CEST) --] gpg: Signature faite le jeu. 23 avril 2026 10:23:02 CEST avec la clef RSA d'identifiant 12345678 gpg: Bonne signature de « rantanplan (chien_le_plus_bête_de_l_ouest) <Rantanplan> » [-- Fin de sortie PGP --]
[-- Les données suivantes sont signées --]
ceci est un test signature -- Privilégiez et promouvez les logiciels libres (i.e., LibreOffice, FireFox, ThunderBird, Mastodon, Jitsi, Gimp, Audacity, VLC, 7-Zip, KeePass2, GNUpg...). Redonnez vie à votre ancien ordinateur avec Linux : C'est bon pour la planète !
[-- Fin des données signées --]
Et le message reçu par joe.dalton dans son client messagerie Sylpheed :
Citer
Afficher (cliquer pour afficher/cacher)
From: rantanplan@daisy.town To: joe.dalton@dalton.city Subject: test signature Date: Thu, 23 Apr 2026 10:23:02 +0200
ceci est un test signature -- Privilégiez et promouvez les logiciels libres (i.e., LibreOffice, FireFox, ThunderBird, Mastodon, Jitsi, Gimp, Audacity, VLC, 7-Zip, KeePass2, GNUpg...). Redonnez vie à votre ancien ordinateur avec Linux : C'est bon pour la planète !
[signature.asc application/pgp-signature (456B)]
Note : la dernière ligne entre '[' et ']' identifie une pièce jointe qui correspond à la signature gpg.
D'ailleurs, voici le contenu de signature.asc : Afficher (cliquer pour afficher/cacher)