From 9bdfa72f032c9c8f29affabf850d23b1591f7f98 Mon Sep 17 00:00:00 2001 From: gabrix73 Date: Sun, 31 May 2026 03:13:09 +0200 Subject: Add vim-yubisigner wrapper and installation instructions - Add scripts/vim-yubisigner (editor wrapper for YubiKey signing) - Update README with complete installation steps for yubisigner-cli - Include code blocks for building and installing wrapper --- README.md | 18 ++++++++++---- scripts/vim-yubisigner | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) create mode 100755 scripts/vim-yubisigner diff --git a/README.md b/README.md index 333166f..7a28025 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,20 @@ apt install neomutt tor torsocks swaks For automatic post signing with YubiKey PIV Ed25519: -1. Install [yubisigner](https://github.com/Ch1ffr3punk/yubisigner) dependencies (Go, piv-go, etc.) -2. Build [yubisigner-cli](https://git.virebent.art/virebent/yubisigner-cli) (CLI version of yubisigner GUI) -3. Configure YubiKey PIV slot 9c with Ed25519 key -4. Install `vim-yubisigner` wrapper script +1. Configure YubiKey PIV slot 9c with Ed25519 key (one-time setup) +2. Install [yubisigner-cli](https://git.virebent.art/virebent/yubisigner-cli): + ```bash + cd ~/bin + git clone https://git.virebent.art/virebent/yubisigner-cli + cd yubisigner-cli + go build -o yubisigner-cli main.go + ``` +3. Install `vim-yubisigner` wrapper from this repo: + ```bash + mkdir -p ~/bin + cp scripts/vim-yubisigner ~/bin/vim-yubisigner + chmod +x ~/bin/vim-yubisigner + ``` The mail2news account is pre-configured to use `vim-yubisigner` as editor, which automatically signs messages with YubiKey after editing. diff --git a/scripts/vim-yubisigner b/scripts/vim-yubisigner new file mode 100755 index 0000000..45d1c3d --- /dev/null +++ b/scripts/vim-yubisigner @@ -0,0 +1,65 @@ +#!/bin/bash +# Vim wrapper that auto-signs with yubisigner-cli after editing +# Used by NeoMutt mail2news account +# Creates PGP-like clearsign format with yubisigner signature + +set -euo pipefail + +# First argument is the file to edit +FILE="$1" + +# Open vim for editing +vim "$FILE" + +# Save original message +ORIGINAL_MSG=$(cat "$FILE") + +# After vim exits, sign the message +echo "" +echo "Signing message with YubiKey..." + +# Kill gpg-agent to release YubiKey (it will auto-restart later) +echo "Releasing YubiKey from gpg-agent..." +gpgconf --kill gpg-agent 2>/dev/null || true +sleep 1 + +# Sign with yubisigner-cli (PIN will be prompted) +if ! "$HOME/bin/yubisigner-cli/yubisigner-cli" \ + --input "$FILE" \ + --author "Gab Virebent" \ + --email "gabriel1@virebent.art" \ + --url "https://contact.virebent.art" \ + --comment "Posted via NeoMutt mail2news"; then + echo "" + echo "ERROR: yubisigner-cli failed!" + echo "Press ENTER to continue WITHOUT signature..." + read + exit 0 +fi + +# Check if signature was created +if [ ! -f "$FILE.sig" ]; then + echo "" + echo "ERROR: Signature file not created!" + echo "Press ENTER to continue WITHOUT signature..." + read + exit 0 +fi + +# Create clearsign format (like PGP clearsign but with yubisigner signature) +{ + echo "-----BEGIN YUBISIGNER SIGNED MESSAGE-----" + echo "Hash: SHA256" + echo "" + echo "$ORIGINAL_MSG" + echo "" + cat "$FILE.sig" +} > "$FILE.tmp" + +# Replace original file with clearsign version +mv "$FILE.tmp" "$FILE" + +# Cleanup +rm -f "$FILE.sig" + +echo "Message signed successfully" -- cgit v1.2.3