Add readme and termux install script

This commit is contained in:
F
2025-12-20 13:00:50 +01:00
committed by GitHub
parent 874eb477d3
commit 6286dab887
4 changed files with 1017 additions and 0 deletions

286
plugins/PGP_QUICK_START.md Normal file
View File

@@ -0,0 +1,286 @@
# PGP Plugin - Quick Start Guide (Post-Installation)
## If Key Generation Failed (shows "No key configured")
### On Termux (Android)
**Option 1: Quick Fix Script (Recommended)**
```bash
# Run the automated fix
bash termux_pgp_fix.sh
# Then in LXMF client:
pgp keygen
```
**Option 2: Manual Steps**
```bash
# Install/reinstall GPG
pkg update
pkg install gnupg -y
# Install Python library
pip install python-gnupg --break-system-packages
# Verify installation
gpg --version
# Start LXMF client and run:
pgp diagnose
pgp keygen
```
### On Windows
Key generation should work automatically. If not:
```bash
# Verify GPG is installed
gpg --version
# If not found, download from: https://gnupg.org/download/
# In LXMF client:
pgp keygen
```
### On Linux/macOS
```bash
# Install GPG if needed
sudo apt install gnupg # Debian/Ubuntu
brew install gnupg # macOS
# Install Python library
pip install python-gnupg --user
# In LXMF client:
pgp keygen
```
## Step-by-Step: Getting Your PGP Working
### 1. Run Diagnostic
In your LXMF client, type:
```
pgp diagnose
```
This will tell you exactly what's wrong. Look for:
- ✓ GPG Binary: Should be "Found"
- ✓ Python GnuPG Library: Should be loaded
- ✓ Keyring Directory: Should be writable
- ✓ GPG version: Should show a version number
### 2. Generate Your Key
Once diagnostic shows all ✓ marks:
```
pgp keygen
```
**On mobile/Termux:** This may take 30-60 seconds. **Move your device around** to generate entropy.
Expected output:
```
📝 Generating new PGP key...
PGP PLUGIN - FIRST TIME SETUP
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Name: YourName
Email: a1b2c3d4e5f6@lxmf.local
Using GPG version: 2.4.0
Starting key generation...
✓ PGP key pair generated!
✓ Key ID: 1234567890ABCDEF1234567890ABCDEF12345678
✓ Key generation complete!
```
### 3. Verify It Worked
```
pgp status
```
Should show:
```
🔑 Your Key:
Key ID: 1234567890ABCDEF...
Name: YourName <...@lxmf.local>
Type: RSA 2048-bit
```
### 4. Export Your Public Key
```
pgp export
```
Copy the output (everything from `-----BEGIN PGP PUBLIC KEY BLOCK-----` to `-----END PGP PUBLIC KEY BLOCK-----`)
### 5. Share Keys with Contacts
**Send your key to a contact:**
```
send Alice -----BEGIN PGP PUBLIC KEY BLOCK----- [paste entire key] -----END PGP PUBLIC KEY BLOCK-----
```
**When you receive a contact's key:**
```
pgp trust Alice -----BEGIN PGP PUBLIC KEY BLOCK----- [paste their key] -----END PGP PUBLIC KEY BLOCK-----
```
### 6. Send Encrypted Messages
**Method 1: Direct command**
```
pgp send Alice Hello, this is encrypted!
```
**Method 2: Enable auto-mode**
```
pgp set auto_encrypt on
pgp set auto_sign on
# Now regular send is encrypted:
send Alice This is also encrypted!
```
## Common Issues & Solutions
### Issue: "Failed to generate key"
**Solution:**
```bash
# On Termux - improve entropy
pkg install haveged
haveged -w 1024 &
# Try again
pgp keygen
```
### Issue: "GPG not properly initialized"
**Solution:**
```bash
# Verify GPG binary exists
gpg --version
# If not found, reinstall:
# Termux: pkg install gnupg
# Linux: sudo apt install gnupg
# macOS: brew install gnupg
```
### Issue: "Could not get GPG version"
**Solution:**
```bash
# Reinstall python-gnupg
pip uninstall python-gnupg
pip install python-gnupg --break-system-packages
```
### Issue: Key generation hangs forever
**On Termux:**
- Move your device around (generates entropy)
- Install haveged: `pkg install haveged`
- Wait up to 2 minutes
**On any system:**
- Open another terminal and run: `ls -R /` (generates disk activity)
- Move mouse around (on desktop)
- Press random keys in another window
### Issue: "Permission denied" on keyring
**Solution:**
```bash
# Find keyring path with: pgp diagnose
# Then fix permissions:
chmod 700 ~/.local/share/lxmf_client_storage/plugins/pgp/keyring
```
## What to Do If Nothing Works
### Nuclear Option: Manual Key + Config
1. **Generate key outside plugin:**
```bash
gpg --full-gen-key
# Choose: RSA 2048, no expiration
# Use any name/email
```
2. **Get the key ID:**
```bash
gpg --list-keys
# Look for the long hex fingerprint
```
3. **Edit plugin config:**
```bash
# Find your storage path with: pgp diagnose
nano ~/.local/share/lxmf_client_storage/plugins/pgp/config.json
```
Add:
```json
{
"my_key_id": "YOUR_FINGERPRINT_HERE",
"auto_encrypt": false,
"auto_sign": true,
"auto_decrypt": true,
"auto_verify": true
}
```
4. **Restart LXMF client**
5. **Check status:**
```
pgp status
```
Should now show your manually created key!
## Verification Checklist
Use this to verify everything is working:
- [ ] `pgp diagnose` shows all ✓ marks
- [ ] `pgp keygen` completes without errors
- [ ] `pgp status` shows a key ID
- [ ] `pgp list` shows your key with ★ marker
- [ ] `pgp export` shows your public key
- [ ] Can send encrypted message to yourself (if you trust your own key)
## Getting Help
If you're still stuck:
1. Run `pgp diagnose` and save the output
2. Try the manual key generation method above
3. Check the full TERMUX_TROUBLESHOOTING.md guide
4. Verify GPG works outside the plugin: `echo "test" | gpg --armor --encrypt -r your@email.local`
## Success! Now What?
Once you have a working key:
1. **Export and share:** `pgp export`
2. **Import contacts' keys:** `pgp trust <name> <their_key>`
3. **Send encrypted:** `pgp send <name> <message>`
4. **Or enable auto-mode:**
```
pgp set auto_encrypt on
pgp set auto_sign on
```
Enjoy secure messaging! 🔐

View File

@@ -0,0 +1,302 @@
# PGP Plugin - Termux Troubleshooting Guide
## Issue: "No key configured" after plugin loads
This happens when key generation fails silently on Termux. Here's how to fix it:
### Step 1: Verify GPG is installed
```bash
gpg --version
```
**If not installed:**
```bash
pkg install gnupg -y
```
### Step 2: Verify python-gnupg is installed
```bash
pip list | grep gnupg
```
**If not installed:**
```bash
pip install python-gnupg --break-system-packages
```
### Step 3: Run diagnostic
Start your LXMF client and run:
```
pgp diagnose
```
This will show you:
- ✓ GPG binary status
- ✓ Python library status
- ✓ Keyring directory permissions
- ✓ Existing keys
- 💡 Specific recommendations
### Step 4: Manual key generation
If auto-generation failed, generate manually:
```
pgp keygen
```
This will:
1. Prompt for confirmation
2. Show detailed progress
3. Display any errors that occur
4. Give you troubleshooting steps if it fails
### Common Termux Issues
#### Issue: GPG not found
**Solution:**
```bash
pkg update
pkg install gnupg -y
```
#### Issue: Permission denied on keyring
**Solution:**
```bash
# Find your keyring directory (shown in "pgp diagnose")
chmod 700 ~/.local/share/lxmf_client_storage/plugins/pgp/keyring
```
#### Issue: Key generation hangs
**Cause:** Insufficient entropy on mobile devices
**Solutions:**
1. **Move your device around** while key generation runs (adds entropy)
2. **Install haveged** (entropy generator):
```bash
pkg install haveged
haveged -w 1024
```
Then try `pgp keygen` again
3. **Use smaller key** (edit plugin temporarily):
- Not recommended for production use
- Only if you're testing
#### Issue: "GPG version: None"
**Cause:** GPG binary not in PATH or python-gnupg can't find it
**Solution:**
```bash
# Check where GPG is installed
which gpg
# Should show: /data/data/com.termux/files/usr/bin/gpg
# If not found, reinstall:
pkg reinstall gnupg
```
## Manual Key Generation (Outside Plugin)
If the plugin continues to fail, you can generate a key manually and configure the plugin to use it:
### Step 1: Generate key with GPG directly
```bash
gpg --full-gen-key
```
Choose:
- Key type: **RSA and RSA**
- Key size: **2048**
- Expiration: **0** (never)
- Name: **Your LXMF display name**
- Email: **anything@lxmf.local**
- Passphrase: **Leave empty** (or remember it)
### Step 2: List your keys
```bash
gpg --list-keys
```
Look for output like:
```
pub rsa2048 2024-12-20 [SC]
1234567890ABCDEF1234567890ABCDEF12345678
uid [ultimate] YourName <anything@lxmf.local>
```
The long hex string is your **fingerprint**.
### Step 3: Configure plugin to use this key
Edit the plugin config:
```bash
nano ~/.local/share/lxmf_client_storage/plugins/pgp/config.json
```
Add or modify:
```json
{
"my_key_id": "1234567890ABCDEF1234567890ABCDEF12345678",
"auto_encrypt": false,
"auto_sign": true,
"auto_decrypt": true,
"auto_verify": true,
"reject_unsigned": false,
"reject_unencrypted": false
}
```
Replace the fingerprint with yours from step 2.
### Step 4: Restart LXMF client
Exit and restart. Check status:
```
pgp status
```
Should now show your key!
## Still Having Issues?
### Get detailed error information
Run diagnostic:
```
pgp diagnose
```
Save the output and check:
1. Is GPG binary found? ✓
2. Is python-gnupg loaded? ✓
3. Is keyring writable? ✓
4. What's the specific error?
### Test GPG directly
```bash
# Create test message
echo "test" > test.txt
# Try to encrypt it
gpg --armor --encrypt --recipient your@email.local test.txt
# If this fails, the issue is with GPG itself, not the plugin
```
### Check permissions
```bash
# Plugin directories should be readable/writable
ls -la ~/.local/share/lxmf_client_storage/plugins/pgp/
# Should show:
# drwx------ keyring/
# -rw-r--r-- config.json
```
Fix if needed:
```bash
chmod 700 ~/.local/share/lxmf_client_storage/plugins/pgp/keyring
chmod 644 ~/.local/share/lxmf_client_storage/plugins/pgp/config.json
```
## Working Configuration Example
Here's what a working Termux setup looks like:
```bash
# 1. GPG installed and working
$ gpg --version
gpg (GnuPG) 2.4.0
...
# 2. Python library installed
$ pip list | grep gnupg
python-gnupg 0.5.1
# 3. In LXMF client
> pgp diagnose
🔍 GPG Binary:
✓ Found: gpg (GnuPG) 2.4.0
🐍 Python GnuPG Library:
✓ Module loaded: ...
📁 Keyring Directory:
Path: /data/data/com.termux/files/home/.local/share/lxmf_client_storage/plugins/pgp/keyring
Exists: True
Writable: True
🔧 Python-GnuPG Status:
✓ GPG version: 2.4.0
🔑 Current Keys in Keyring:
Found 1 key(s):
★ 1234567890ABCDEF: YourName <hash@lxmf.local>
⚙️ Plugin Configuration:
Configured key ID: 1234567890ABCDEF1234567890ABCDEF12345678
# 4. Status shows working key
> pgp status
🔑 Your Key:
Key ID: 1234567890ABCDEF1234567890ABCDEF12345678
Name: YourName <hash@lxmf.local>
Type: RSA 2048-bit
```
## Quick Fix Checklist
Run these commands in order:
```bash
# 1. Update and install GPG
pkg update && pkg install gnupg -y
# 2. Install Python library
pip install python-gnupg --break-system-packages
# 3. Test GPG
gpg --version
# 4. In LXMF client - diagnose
pgp diagnose
# 5. Generate key if needed
pgp keygen
# 6. Verify it worked
pgp status
```
## Need More Help?
If you're still stuck:
1. Run `pgp diagnose` and save output
2. Check what specific error appears during `pgp keygen`
3. Try manual GPG key generation (see above)
4. Check Termux logs for errors
The most common fix is simply:
```bash
pkg install gnupg
pip install python-gnupg --break-system-packages
```
Then in LXMF:
```
pgp keygen
```

311
plugins/PGP_V2_README.md Normal file
View File

@@ -0,0 +1,311 @@
# PGP Plugin v2 - Fixed Version
## What's New in v2
**Improved key generation** with better error handling
**Diagnostic command** (`pgp diagnose`) to troubleshoot issues
**Termux-specific fixes** for mobile key generation
**Better error messages** that tell you exactly what's wrong
**Manual key configuration** support if auto-generation fails
## For Termux Users: Key Not Generated?
### Quick Fix (Run this in Termux):
```bash
bash termux_pgp_fix.sh
```
Then in LXMF client:
```
pgp keygen
```
### Manual Steps:
1. **Install GPG:**
```bash
pkg install gnupg -y
```
2. **Install Python library:**
```bash
pip install python-gnupg --break-system-packages
```
3. **In LXMF client - diagnose:**
```
pgp diagnose
```
4. **Generate key:**
```
pgp keygen
```
**Pro tip:** Move your device around during key generation (helps with entropy)
## Installation
### Replace Old Plugin
If you already have pgp.py installed:
```bash
# Backup old version
cp ~/.local/share/lxmf_client_storage/plugins/pgp.py ~/.local/share/lxmf_client_storage/plugins/pgp.py.backup
# Install new version
cp pgp_v2.py ~/.local/share/lxmf_client_storage/plugins/pgp.py
# Restart LXMF client
```
### New Installation
```bash
# Copy plugin to plugins directory
cp pgp_v2.py ~/.local/share/lxmf_client_storage/plugins/pgp.py
# Restart LXMF client
```
## New Commands
### pgp diagnose
Shows detailed diagnostic information:
```
pgp diagnose
```
Output includes:
- ✓ GPG binary status
- ✓ Python library status
- ✓ Keyring directory permissions
- ✓ Current keys in keyring
- 💡 Specific recommendations to fix issues
### pgp keygen (improved)
Now with:
- Better progress indication
- Detailed error messages
- Troubleshooting tips if it fails
- Works even if first auto-generation failed
## Troubleshooting
### No Key After First Load
**This is the most common issue on Termux.**
**Solution:**
```
# 1. Run diagnostic
pgp diagnose
# 2. Follow any recommendations shown
# 3. Generate key manually
pgp keygen
# 4. Verify
pgp status
```
### Key Generation Hangs
**On Termux:**
- Move your device around (generates entropy)
- Install haveged: `pkg install haveged && haveged -w 1024 &`
- Wait up to 2 minutes
**On any system:**
- Do disk-intensive operations in another terminal
- Move mouse / type random keys (on desktop)
### "GPG not properly initialized"
```bash
# Check GPG is installed
gpg --version
# If not found:
# Termux: pkg install gnupg
# Linux: sudo apt install gnupg
# macOS: brew install gnupg
```
### "Could not get GPG version"
```bash
# Reinstall python-gnupg
pip install python-gnupg --break-system-packages --upgrade
```
## Manual Key Configuration
If automatic generation keeps failing, you can create a key manually and configure the plugin to use it:
### Step 1: Generate key with GPG
```bash
gpg --full-gen-key
```
Choose:
- Type: RSA and RSA
- Size: 2048
- Expiration: 0 (never)
- Name: Your LXMF name
- Email: anything@lxmf.local
### Step 2: Get key fingerprint
```bash
gpg --list-keys --fingerprint
```
Copy the long hex fingerprint (40 characters)
### Step 3: Configure plugin
Edit config file:
```bash
nano ~/.local/share/lxmf_client_storage/plugins/pgp/config.json
```
Set:
```json
{
"my_key_id": "YOUR_40_CHARACTER_FINGERPRINT_HERE",
"auto_encrypt": false,
"auto_sign": true,
"auto_decrypt": true,
"auto_verify": true
}
```
### Step 4: Restart LXMF
Exit and restart the client. Run:
```
pgp status
```
Should now show your manually configured key!
## Files in This Package
- **pgp_v2.py** - Updated plugin with fixes
- **QUICK_START_FIX.md** - Quick guide to fix key generation issues
- **TERMUX_TROUBLESHOOTING.md** - Comprehensive Termux troubleshooting
- **termux_pgp_fix.sh** - Automated fix script for Termux
- **PGP_PLUGIN_README.md** - Full documentation
- **PGP_USAGE_EXAMPLES.md** - 10 detailed usage examples
## Quick Start (After Fixing Key)
```
# 1. Verify key is configured
pgp status
# 2. Export your public key
pgp export
# 3. Share with contact via LXMF
send Bob -----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----
# 4. Import their key when received
pgp trust Bob -----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----
# 5. Send encrypted message
pgp send Bob Hello securely!
# 6. Or enable auto-mode
pgp set auto_encrypt on
send Bob This is also encrypted!
```
## Command Reference
### Essential Commands
| Command | Description |
|---------|-------------|
| `pgp diagnose` | **NEW** - Diagnose installation issues |
| `pgp keygen` | **IMPROVED** - Generate/regenerate key |
| `pgp status` | Show current configuration |
| `pgp export` | Get your public key to share |
| `pgp trust <contact> <key>` | Import contact's public key |
| `pgp send <contact> <msg>` | Send encrypted message |
### Settings
| Command | Description |
|---------|-------------|
| `pgp set auto_encrypt on/off` | Auto-encrypt all messages |
| `pgp set auto_sign on/off` | Auto-sign all messages |
| `pgp set auto_decrypt on/off` | Auto-decrypt incoming |
| `pgp set auto_verify on/off` | Auto-verify signatures |
## What Changed from v1
### Key Generation
- ✅ Better error handling
- ✅ Shows GPG version before attempting generation
- ✅ Displays detailed error messages
- ✅ Gives specific troubleshooting steps if it fails
- ✅ Works better on low-entropy devices (mobile)
### Diagnostics
- ✅ New `pgp diagnose` command
- ✅ Checks GPG binary
- ✅ Checks Python library
- ✅ Checks permissions
- ✅ Lists all keys in keyring
- ✅ Shows specific recommendations
### Error Messages
- ✅ More informative
- ✅ Include solutions
- ✅ Point to relevant documentation
### Documentation
- ✅ Termux-specific troubleshooting guide
- ✅ Quick start guide for fixing issues
- ✅ Automated fix script
## Still Having Issues?
1. **Run diagnostic:** `pgp diagnose`
2. **Read the output** - it will tell you what's wrong
3. **Check guides:**
- QUICK_START_FIX.md - Fast solutions
- TERMUX_TROUBLESHOOTING.md - Detailed Termux guide
- PGP_PLUGIN_README.md - Full documentation
4. **Try automated fix** (Termux only):
```bash
bash termux_pgp_fix.sh
```
5. **Manual key generation** (if all else fails) - see above
## Compatibility
- ✅ Termux (Android) - **Improved in v2**
- ✅ Windows - Works well
- ✅ Linux - Works well
- ✅ macOS - Works well
## Requirements
- GPG/GnuPG 2.x
- python-gnupg library
- LXMF CLI client
## Support
The diagnostic command (`pgp diagnose`) will tell you exactly what's wrong and how to fix it. Run it first before seeking help!

118
plugins/termux_pgp_fix.sh Normal file
View File

@@ -0,0 +1,118 @@
#!/data/data/com.termux/files/usr/bin/bash
# Quick fix script for PGP plugin on Termux
echo "======================================"
echo "PGP Plugin - Termux Quick Fix"
echo "======================================"
echo ""
# Step 1: Update packages
echo "📦 Updating packages..."
pkg update -y
echo "✓ Done"
echo ""
# Step 2: Install GPG
echo "🔐 Installing GnuPG..."
pkg install gnupg -y
echo "✓ Done"
echo ""
# Step 3: Install python-gnupg
echo "🐍 Installing python-gnupg..."
pip install python-gnupg --break-system-packages --upgrade
echo "✓ Done"
echo ""
# Step 4: Verify GPG
echo "🔍 Verifying GPG installation..."
if command -v gpg &> /dev/null; then
gpg --version | head -n 1
echo "✓ GPG is working"
else
echo "❌ GPG not found - something went wrong"
exit 1
fi
echo ""
# Step 5: Check entropy (optional but helpful)
echo "🎲 Installing entropy generator (optional)..."
if ! command -v haveged &> /dev/null; then
pkg install haveged -y 2>/dev/null
if [ $? -eq 0 ]; then
echo "✓ Haveged installed (helps with key generation)"
else
echo "⚠ Haveged not available (not critical)"
fi
else
echo "✓ Haveged already installed"
fi
echo ""
# Step 6: Check keyring permissions
echo "🔑 Checking keyring directory..."
KEYRING_DIR="$HOME/.local/share/lxmf_client_storage/plugins/pgp/keyring"
if [ -d "$KEYRING_DIR" ]; then
chmod 700 "$KEYRING_DIR"
echo "✓ Keyring permissions fixed: $KEYRING_DIR"
else
echo "⚠ Keyring directory doesn't exist yet (will be created on first run)"
fi
echo ""
# Step 7: Test GPG
echo "🧪 Testing GPG functionality..."
TEST_DIR=$(mktemp -d)
cd "$TEST_DIR"
# Create test key batch file
cat > gpg-test-batch <<EOF
%no-protection
Key-Type: RSA
Key-Length: 1024
Name-Real: Test User
Name-Email: test@test.local
Expire-Date: 0
EOF
# Try to generate a test key
echo " Generating test key (this may take 10-30 seconds)..."
if timeout 60 gpg --batch --gen-key gpg-test-batch 2>&1 | grep -q "marked as ultimately trusted"; then
echo "✓ GPG can generate keys successfully!"
# Clean up test key
TEST_KEY=$(gpg --list-keys --with-colons | grep "^fpr" | head -n 1 | cut -d: -f10)
if [ -n "$TEST_KEY" ]; then
gpg --batch --yes --delete-secret-keys "$TEST_KEY" 2>/dev/null
gpg --batch --yes --delete-keys "$TEST_KEY" 2>/dev/null
fi
else
echo "⚠ GPG test key generation had issues"
echo " This might be due to low entropy on your device"
echo " Try moving your phone around during key generation"
fi
cd -
rm -rf "$TEST_DIR"
echo ""
# Done
echo "======================================"
echo "Setup Complete!"
echo "======================================"
echo ""
echo "✅ GPG installed and verified"
echo "✅ Python library installed"
echo "✅ Permissions configured"
echo ""
echo "Next steps:"
echo "1. Start your LXMF client"
echo "2. Run: pgp diagnose"
echo "3. Run: pgp keygen"
echo "4. Run: pgp status"
echo ""
echo "If key generation still fails:"
echo "• Move your device around (adds entropy)"
echo "• Try: haveged -w 1024 &"
echo "• See: TERMUX_TROUBLESHOOTING.md"
echo ""