Skip to content

jabberwock/yubitui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

359 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

YubiTUI πŸ”

A blazingly fast, intelligent TUI for YubiKey management

YubiTUI is a terminal user interface (TUI) written in Rust that provides comprehensive YubiKey management with a focus on SSH and GPG key operations. It intelligently detects configuration issues, guides users through secure setup, and provides full access to all YubiKey features.

Features

🎯 Core Capabilities

  • Smart Diagnostics: Automatically detects gpg-agent issues, configuration problems, and locked keys
  • PIN Management: Check retry counters, detect locks, unblock PINs with admin PIN
  • Key Import/Generation: Import existing keys or generate new ones directly on the YubiKey
  • SSH Configuration: Guide users through the optimal setup for SSH authentication
  • Multi-Model Support: Automatically detects YubiKey model and adapts features accordingly
  • Card Editing: Full access to all gpg --card-edit functionality through an intuitive UI

πŸš€ Performance

  • Native Speed: Written in Rust for sub-millisecond rendering
  • Efficient Backend: Direct PC/SC communication via pcsc crate
  • Zero Overhead: Immediate-mode rendering with minimal allocations

🧠 Intelligence

  • Configuration Analysis: Detects missing or misconfigured gpg-agent, scdaemon, pcscd
  • Lock Detection: Identifies PIN retry counter status and provides recovery options
  • Key Recognition: Understands why keys aren't being detected and suggests fixes
  • Best Practices: Recommends secure, efficient configurations for SSH usage

Architecture

Technology Stack

  • TUI Framework: Ratatui with Crossterm backend
  • YubiKey Communication:
    • yubikey crate for PIV operations (via PC/SC)
    • openpgp-card crate for OpenPGP card operations
    • Direct gpg CLI integration for card editing
  • State Management: Elm-inspired architecture with message passing

Key Components

src/
β”œβ”€β”€ main.rs              # Entry point, TUI initialization
β”œβ”€β”€ app.rs               # Application state and event loop
β”œβ”€β”€ ui/                  # UI rendering
β”‚   β”œβ”€β”€ mod.rs
β”‚   β”œβ”€β”€ dashboard.rs     # Main dashboard view
β”‚   β”œβ”€β”€ diagnostics.rs   # Configuration diagnostics view
β”‚   β”œβ”€β”€ keys.rs          # Key management view
β”‚   β”œβ”€β”€ pin.rs           # PIN management view
β”‚   └── ssh.rs           # SSH configuration wizard
β”œβ”€β”€ yubikey/             # YubiKey operations
β”‚   β”œβ”€β”€ mod.rs
β”‚   β”œβ”€β”€ detection.rs     # Device detection and model info
β”‚   β”œβ”€β”€ piv.rs           # PIV operations
β”‚   β”œβ”€β”€ openpgp.rs       # OpenPGP card operations
β”‚   β”œβ”€β”€ pin.rs           # PIN/PUK operations
β”‚   └── ssh.rs           # SSH-specific operations
β”œβ”€β”€ diagnostics/         # System diagnostics
β”‚   β”œβ”€β”€ mod.rs
β”‚   β”œβ”€β”€ gpg_agent.rs     # GPG agent detection/analysis
β”‚   β”œβ”€β”€ scdaemon.rs      # Scdaemon configuration
β”‚   β”œβ”€β”€ pcscd.rs         # PC/SC daemon status
β”‚   └── ssh_agent.rs     # SSH agent configuration
└── utils/
    β”œβ”€β”€ mod.rs
    β”œβ”€β”€ gpg_cli.rs       # GPG CLI wrapper
    └── config.rs        # Configuration helpers

Requirements

Runtime Dependencies

  • GPG 2.1+: For OpenPGP operations and card editing
  • PC/SC Lite: For smart card communication (pcscd daemon)
  • YubiKey: Firmware 4.0+ recommended (full feature support)

Build Dependencies

  • Rust 1.75+: Latest stable Rust toolchain
  • PC/SC Development Libraries:
    • macOS: brew install pcsc-lite
    • Linux: apt-get install libpcsclite-dev or equivalent
    • Windows: Windows SDK (pre-installed)

Installation

# Clone the repository
git clone https://github.com/yourusername/yubitui
cd yubitui

# Build and run
cargo run --release

Usage

# Launch the TUI
yubitui

# Quick diagnostics
yubitui --check

# Show detected YubiKeys
yubitui --list

# Enable debug logging
yubitui --debug

Note: When running in TUI mode, logs are written to your system's temp directory (e.g., /tmp/yubitui.log on Linux/macOS, %TEMP%\yubitui.log on Windows) to avoid interfering with the display.

Navigation

  • Tab / Shift+Tab: Navigate between sections
  • ← β†’ ↑ ↓: Navigate within sections
  • Enter: Select / Activate
  • Esc: Go back / Cancel
  • q: Quit
  • ?: Show help

Note: Mouse capture is intentionally disabled to allow text selection and copying. Use keyboard navigation instead.

YubiKey Model Support

Model PIV OpenPGP FIDO2 Firmware Detection
YubiKey 5 Series βœ… βœ… βœ… βœ…
YubiKey 4 Series βœ… βœ… ❌ βœ…
YubiKey NEO ⚠️ βœ… ❌ βœ…

⚠️ = Limited support

Development

Running Tests

# Run all tests
cargo test

# Run tests with a YubiKey connected (requires device)
cargo test --features device-tests -- --ignored

# Run with logging
RUST_LOG=debug cargo run

Code Structure Philosophy

  • Separation of Concerns: UI rendering separate from business logic
  • Type Safety: Leverage Rust's type system to prevent invalid states
  • Error Handling: Comprehensive error types with user-friendly messages
  • Testability: Mock YubiKey operations for CI/CD testing

Roadmap

Phase 1: Core Functionality βœ…

  • Project structure
  • YubiKey detection
  • Basic dashboard UI
  • PIN retry counter display
  • GPG agent diagnostics

Phase 2: Key Management

  • View existing keys
  • Import keys to card (via GPG)
  • Generate keys on-device
  • Key attribute configuration

Phase 3: SSH Integration

  • SSH configuration wizard
  • SSH agent integration
  • Public key export
  • authorized_keys management

Phase 4: Advanced Features

  • Touch policy configuration
  • Attestation support
  • Multiple YubiKey support
  • Backup/restore workflows

Contributing

Contributions welcome! Please read CONTRIBUTING.md for guidelines.

Security

⚠️ IMPORTANT: This tool handles sensitive cryptographic material. Always:

  • Verify signatures on releases
  • Backup your keys before any destructive operations
  • Use the reset function only when you understand the consequences
  • Change default PINs immediately after setup

License

Apache-2.0 OR MIT

Acknowledgments

See Also

About

Cross-platform YubiKey management and automated provisioning

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors

Languages