Hardware Security Guides
Comprehensive guides for using Ledger hardware wallets with this Nix configuration.
Overview
Section titled “Overview”This section covers hardware-backed security using Ledger Nano S for:
- GPG signing (git commits, messages, files)
- SSH authentication (GitHub, servers)
- Secrets management (SOPS encryption)
All operations require physical confirmation on your device, providing hardware-level security.
Documentation in This Section
Section titled “Documentation in This Section”Start here for complete Ledger configuration from scratch.
Covers:
- Installing Ledger Live and SSH/GPG Agent app
- Initializing GPG keys on device
- Configuring SSH authentication
- Setting up SOPS secrets management
- Troubleshooting and verification
Status: ✅ Complete step-by-step guide
Deep dive into hardware security architecture and implementation.
Covers:
- Comprehensive hardware wallet theory
- Security model and threat analysis
- Advanced configuration patterns
- Integration with cloud and CI/CD
- Best practices and operational security
Status: ✅ Comprehensive reference
Using Ledger for GPG operations and git commit signing.
Covers:
- GPG key management on Ledger
- Git commit signing (automatic)
- Manual GPG operations (sign, encrypt, verify)
- GitHub/GitLab integration
- Troubleshooting agent issues
Status: ✅ Complete with examples
SSH authentication with hardware-backed keys.
Covers:
- SSH agent configuration (GPG agent vs ledger-agent)
- Getting SSH public keys from Ledger
- Adding keys to GitHub/GitLab/servers
- Troubleshooting connection issues
- Advanced usage (forwarding, multiple keys)
Status: ✅ Complete with troubleshooting
Quick Start
Section titled “Quick Start”Prerequisites
Section titled “Prerequisites”- Ledger Nano S device
- USB cable
- macOS with this Nix config installed
Installation (5 minutes)
Section titled “Installation (5 minutes)”# 1. Enable hardware-security profile in your user config# In home/users/yourname.nix:imports = [ ../../nix/profiles/hardware-security.nix];
# 2. Rebuilddarwin-rebuild switch --flake .#your-hostname
# 3. Install Ledger Live via Homebrewopen -a "Ledger Live"
# 4. Follow Ledger Setup Guide
See Ledger Setup Guide for detailed instructions.
What You Get
Section titled “What You Get”After completing the setup:
GPG Signing ✅
Section titled “GPG Signing ✅”# Automatic git commit signinggit commit -m "message"# Ledger prompts for confirmation
# Verified badge on GitHub
SSH Authentication ✅
Section titled “SSH Authentication ✅”# SSH with hardware keyssh -T git@github.com# Ledger prompts for confirmation
# Works with all SSH serversssh user@server.com
SOPS Secrets ✅
Section titled “SOPS Secrets ✅”# Encrypt/decrypt secrets with Ledgersops nix/secrets/secrets.yaml# Ledger prompts for confirmation
# Safe to commit encrypted secretsgit add nix/secrets/secrets.yaml
Architecture
Section titled “Architecture”┌─────────────────────────────────────────────────────────────┐│ Hardware Security Stack │├─────────────────────────────────────────────────────────────┤│ ││ Application Layer ││ ├── Git (commit signing) ││ ├── SSH (authentication) ││ └── SOPS (secrets encryption) ││ │ ││ ▼ ││ Agent Layer ││ ├── ledger-gpg-agent (GPG operations) ││ └── ledger-ssh-agent (SSH operations) ││ │ ││ ▼ ││ Hardware Layer ││ └── Ledger Nano S ││ ├── Private keys (never leave device) ││ ├── SSH/GPG Agent app ││ └── Physical confirmation required ││ │└─────────────────────────────────────────────────────────────┘
Key Features
Section titled “Key Features”🔐 Hardware Security
Section titled “🔐 Hardware Security”- Private keys on device - Never exposed to computer
- Physical confirmation - Button press for every operation
- Recovery seed - Keys derived from 24-word phrase
- Multi-purpose - One device for GPG, SSH, and secrets
🔄 Nix Integration
Section titled “🔄 Nix Integration”- Declarative config - All settings in Nix files
- Automatic agents - launchd services start on login
- Wrapper scripts - Auto-manage agent lifecycle
- Profile-based - Enable with single import
🛡️ Operational Security
Section titled “🛡️ Operational Security”- Audit trail - All signed commits in Git history
- Platform integration - Verified badges on GitHub
- No plaintext keys - Keys never on disk
- Backup strategy - Recovery phrase + hardware backup
Common Tasks
Section titled “Common Tasks”Get Started
Section titled “Get Started”Daily Usage
Section titled “Daily Usage”# Git commits (automatic signing)git commit -m "message"
# SSH to GitHubssh -T git@github.com
# Edit secretssops nix/secrets/secrets.yaml
Troubleshooting
Section titled “Troubleshooting”Security Model
Section titled “Security Model”Threat Protection
Section titled “Threat Protection”What hardware security protects against:
- ✅ Key theft from compromised computer
- ✅ Malware extracting private keys
- ✅ Unauthorized signing/authentication
- ✅ Key exfiltration over network
- ✅ Accidental key exposure
What it doesn’t protect against:
- ❌ Physical theft of device (PIN protection)
- ❌ Malware after successful authentication
- ❌ Compromised remote systems
- ❌ Social engineering attacks
- ❌ Side-channel attacks on device
Best Practices
Section titled “Best Practices”-
Device Security
- Remove Ledger when not in use
- Lock screen when away from computer
- Use strong PIN (6-8 digits)
- Keep firmware updated
-
Key Management
- Secure 24-word recovery phrase (offline storage)
- Test recovery process periodically
- Consider backup Ledger device
- Use unique keys per purpose
-
Operational Security
- Verify operations before confirming on device
- Audit signed commits regularly
- Rotate secrets periodically
- Monitor agent logs
Troubleshooting
Section titled “Troubleshooting”Ledger Not Detected
Section titled “Ledger Not Detected”- Check USB connection
- Unlock with PIN
- Open SSH/GPG Agent app on device
- Verify screen shows “ready”
Agent Not Running
Section titled “Agent Not Running”# Check processpgrep -f ledger-gpg-agent
# View logstail -f ~/.local/share/ledger-gpg-agent.log
# Restartkillall ledger-gpg-agentledger-gpg-agent --homedir ~/.gnupg-ledger --server --verbose &
Operation Fails
Section titled “Operation Fails”- Ensure Ledger app is open
- Check for confirmation prompt on device
- Press button to confirm
- Check agent logs for errors
See individual guides for specific troubleshooting.
Configuration Reference
Section titled “Configuration Reference”Nix Profile
Section titled “Nix Profile”The hardware-security profile (nix/profiles/hardware-security.nix
) provides:
{ # Packages home.packages = [ ledger-agent ledger-ssh-agent ];
# GPG configuration programs.gpg.enable = true; services.gpg-agent.enable = true;
# Git signing programs.git.signing = { key = "YOUR-GPG-KEY-ID"; signByDefault = true; };
# Launchd services (auto-start agents) launchd.agents = { ledger-gpg-agent = { ... }; ledger-ssh-agent = { ... }; };}
Environment Variables
Section titled “Environment Variables”# GPG home directoryexport GNUPGHOME=~/.gnupg-ledger
# SSH agent socketexport SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
# GPG TTY (for signing)export GPG_TTY=$(tty)
Related Documentation
Section titled “Related Documentation”In This Section
Section titled “In This Section”- Ledger Setup - Complete setup guide
- Ledger Overview - Deep dive
- GPG Signing - Commit signing
- SSH Authentication - SSH with Ledger
Other Sections
Section titled “Other Sections”- SOPS Secrets - Secrets encryption
- Structure Guide - Config architecture
- Troubleshooting - Common issues
External Resources
Section titled “External Resources”- Ledger SSH/GPG Agent - Official app
- trezor-agent - Agent software
- Ledger Developer Docs - Technical docs
- Hardware Security Guide - Best practices
Ready to get started? Follow the Ledger Setup Guide!