A powerful terminal-based SSH connection manager written in Rust, featuring raw SSH terminal functionality directly within the UI panel - no mode switching required!
- Unified Experience: Raw terminal works directly in-panel without mode switching
- Full TUI App Support: vim, nano, emacs, htop, tmux work perfectly in the terminal panel
- Always-Visible Sidebar: Keep your connection list accessible while working
- Modern Interface: Mouse and keyboard navigation with colorful, intuitive UI
- Complete SSH Management: Add, edit, delete SSH keys, groups, and hosts
- vim/nano/emacs work perfectly within the terminal panel
- htop/top/iotop display correctly within the panel bounds
- tmux/screen sessions run seamlessly in the panel
- Interactive shells (Python REPL, database shells) work flawlessly
- Sidebar stays visible while using any TUI application
- Mouse support for clicking on items, buttons, and scrolling
- Keyboard shortcuts for efficient navigation and management
This implementation showcases:
- ANSI escape sequence parsing using the
vtecrate - Styled terminal content rendering within ratatui widget bounds
- Coordination between TUI framework and raw terminal data
- Precise cursor positioning and screen clearing within panels
- Terminal resizing handling for both the UI and SSH PTY
- Async SSH connections with proper PTY management
Fully functional SSH TUI Manager with:
- ✅ Complete UI layout with sidebar panels
- ✅ Configuration file loading and saving (SSH keys, groups, hosts)
- ✅ Panel navigation and focus management
- ✅ Raw terminal panel with VTE parsing
- ✅ Full SSH connection functionality using portable-pty
- ✅ Add/Edit/Delete operations for keys, groups, and hosts
- ✅ Mouse support for all UI interactions
- ✅ Keyboard shortcuts and navigation
- ✅ Modal dialogs with form handling
- ✅ SSH key selector with dropdown interface
- ✅ Colorful dashboard with live statistics
- Rust 1.70+
- A terminal with Unicode and color support
# Clone and build
git clone <this-repo>
cd sshtuirust
cargo build --release
# Run the demo
cargo run- TAB / Shift+TAB: Navigate between panels and buttons
- ↑/↓ Arrow Keys: Navigate within panels and forms
- Enter: Connect to selected host or submit forms
- ESC: Close modals and cancel operations
- Ctrl+N: Add new (Key/Group/Host depending on focused panel)
- Ctrl+E: Edit selected item
- Ctrl+D: Delete selected item
- Ctrl+H: Show help popup
- Ctrl+Q: Quit application or disconnect SSH
- Ctrl+C: Send interrupt to SSH session
- All other keys: Sent directly to SSH terminal
- Left Click: Select items, focus panels, click buttons
- Double Click: Connect to host (in hosts panel)
- Scroll Wheel: Scroll through lists
- Click outside modal: Close modal dialogs
config.rs- Configuration management (JSON-based with auto-save)main.rs- Application entry point and main event loopui.rs- Main UI rendering and layout managementssh.rs- SSH connection handling with portable-ptyterminal_panel.rs- Raw terminal panel with VTE parsingmodal.rs- Modal dialogs for forms and user inputdashboard.rs- Welcome screen and statistics display
- ratatui for TUI framework and widget rendering
- crossterm for terminal control and mouse/keyboard events
- VTE parser for ANSI escape sequence handling
- portable-pty for proper SSH PTY management
- Tokio for async runtime and SSH connections
- Serde for JSON configuration serialization
The RawTerminalPanel struct (in terminal_panel.rs) demonstrates how to:
impl RawTerminalPanel {
pub fn write_ssh_data(&mut self, data: &[u8]) {
// Feed raw SSH data directly to VTE parser
for &byte in data {
self.parser.advance(self, byte);
}
}
pub fn render(&self, frame: &mut Frame) {
// Render styled terminal content within ratatui bounds
// Each character preserves its color, style, and position
}
}The application features:
- Colorful dashboard with live statistics and inspirational quotes
- Focus highlighting with yellow borders and clear visual feedback
- Context-sensitive help displayed at the bottom
- Status messages for user feedback and operation confirmation
- Smooth mouse interaction with click feedback
- Responsive layout that adapts to terminal size changes
Configuration is stored in ~/.sshtui.json and auto-saved when modified:
{
"groups": [
{
"name": "Production",
"color": "red",
"hosts": [
{
"name": "Web Server",
"host": "web.example.com",
"user": "admin",
"port": 22,
"key_path": "/home/user/.ssh/id_rsa"
}
]
},
{
"name": "Development",
"color": "green",
"hosts": [
{
"name": "Dev Server",
"host": "dev.example.com",
"user": "developer",
"port": 2222,
"key_path": "/home/user/.ssh/dev_key"
}
]
}
],
"keys": [
{
"name": "Default Key",
"path": "/home/user/.ssh/id_rsa",
"is_default": true
},
{
"name": "Development Key",
"path": "/home/user/.ssh/dev_key",
"is_default": false
}
]
}- Automatic saving - Changes are persisted immediately
- Color-coded groups - Organize hosts with visual distinction
- SSH key management - Centralized key storage with dropdown selection
- Special "All" group - Automatically shows hosts from all groups
This implementation demonstrates that Rust's lower-level terminal control combined with sophisticated parsing libraries can achieve seamless SSH terminal integration within TUI panels.
Key Technical Insights:
- VTE parser processes SSH escape sequences while ratatui handles the overall layout
- portable-pty provides proper PTY management for stable SSH connections
- Async event handling allows smooth UI updates while maintaining SSH session responsiveness
- Smart focus management enables intuitive navigation between sidebar and terminal
Possible improvements and additions:
- Session management - Save and restore SSH sessions
- Connection profiles - Quick connect with predefined settings
- File transfer integration - SCP/SFTP support within the UI
- Connection health monitoring - Network latency and status indicators
- Scripting support - Automated command execution
- Theme customization - User-defined color schemes
- Connection logging - Session history and command logging
Rust's advantages for this use case:
- Zero garbage collection pauses during intensive terminal operations
- Memory-safe direct manipulation of terminal buffers
- Efficient async I/O with Tokio
- Compile-time optimization of terminal rendering paths
This project demonstrates the feasibility of raw SSH terminal functionality within TUI panels - a significant improvement over mode-based approaches! 🎉