Skip to content

Conversation

tan9
Copy link

@tan9 tan9 commented Sep 11, 2025

Summary

This PR significantly expands LazySSH's SSH configuration support by adding 25+ high-priority fields commonly used by developers and system administrators. The implementation focuses on the most requested features including port forwarding, connection multiplexing, enhanced authentication options, and advanced cryptography settings. Additionally, the UI has been completely reorganized with a tabbed interface for better usability.

What's Changed

🚀 New High-Priority SSH Config Fields

Connection & Proxy Settings:

  • ConnectTimeout - Connection timeout in seconds
  • ConnectionAttempts - Number of connection retry attempts
  • BindAddress - Bind to specific local address (using native -b flag)
  • BindInterface - Bind to network interface with auto-detection dropdown (using native -B flag)

Port Forwarding (Major Feature):

  • LocalForward - Local port forwarding (supports multiple entries)
  • RemoteForward - Remote port forwarding (supports multiple entries)
  • DynamicForward - SOCKS dynamic forwarding (supports multiple entries)

Authentication & Key Management:

  • PubkeyAuthentication - Enable/disable public key auth
  • PasswordAuthentication - Enable/disable password auth
  • PreferredAuthentications - Order of authentication methods
  • IdentitiesOnly - Use only specified identity files
  • AddKeysToAgent - Auto-add keys to SSH agent (yes/no/ask/confirm)
  • IdentityAgent - Custom SSH agent socket path

Agent & X11 Forwarding:

  • ForwardAgent - Enable SSH agent forwarding
  • ForwardX11 - Enable X11 forwarding for GUI applications
  • ForwardX11Trusted - Trusted X11 forwarding

Connection Multiplexing (Performance Feature):

  • ControlMaster - SSH connection multiplexing (yes/no/auto/ask/autoask)
  • ControlPath - Control socket path
  • ControlPersist - Keep control connection alive duration

Connection Reliability:

  • ServerAliveInterval - Server keepalive interval in seconds
  • ServerAliveCountMax - Max server keepalive count
  • Compression - Enable compression
  • TCPKeepAlive - TCP keepalive messages

Security & Cryptography:

  • StrictHostKeyChecking - Host key verification (yes/no/ask/accept-new)
  • UserKnownHostsFile - Custom known hosts file path
  • HostKeyAlgorithms - Preferred host key algorithms
  • MACs - Message Authentication Codes with dropdown (using native -m flag)
  • Ciphers - Encryption algorithms with dropdown (using native -c flag)
  • KexAlgorithms - Key exchange algorithms with dropdown

Command Execution:

  • RequestTTY - Request TTY allocation (yes/no/force/auto)
  • RemoteCommand - Execute command on remote
  • LocalCommand - Execute command locally after connection
  • PermitLocalCommand - Allow LocalCommand execution

Environment Settings:

  • SendEnv - Send environment variables to remote (supports multiple)
  • SetEnv - Set remote environment variables (supports multiple)

Debugging:

  • LogLevel - SSH log verbosity (quiet/fatal/error/info/verbose/debug/debug1/debug2/debug3)
  • BatchMode - Batch mode for non-interactive sessions

🎨 UI/UX Improvements

  • NEW: Tabbed Interface - Replaced single scrollable form with 6 organized tabs:
    • Basic (alias, host, user, port, keys, tags)
    • Connection (proxy, timeout, bind options, keepalive settings)
    • Forwarding (port forwarding, X11, agent forwarding)
    • Authentication (key management, authentication methods)
    • Multiplexing (connection sharing settings)
    • Advanced (security, cryptography, environment, debugging)
  • Clickable tab navigation with visual indicators
  • Smart tab abbreviations for narrow views (Auth→Authentication, Conn→Connection, etc.)
  • Keyboard shortcuts:
    • Ctrl+H / Ctrl+L - Navigate between tabs
    • Ctrl+S - Save
    • Esc - Cancel
  • Circular tab navigation - loops at boundaries for better flow
  • Save/Cancel buttons on each tab for easier access
  • Enhanced dropdowns for all enumerated fields:
    • MACs dropdown with 18 common MAC algorithms
    • Ciphers dropdown with 11 encryption algorithms
    • KexAlgorithms dropdown with 11 key exchange algorithms
    • BindInterface dropdown with auto-detected network interfaces
  • Multi-value field support with comma-separated input
  • Improved visual hierarchy with section headers and grouping

🔧 Technical Improvements

  • Native SSH flags preferred over -o options where available:
    • -m for MACs instead of -o MACs=
    • -c for Ciphers instead of -o Ciphers=
    • -b for BindAddress instead of -o BindAddress=
    • -B for BindInterface instead of -o BindInterface=
    • Plus existing: -p, -i, -J, -L, -R, -D, -A/-a, -X/-x, -Y, -C, -t/-T/-tt, -q/-v/-vv/-vvv
  • Network interface detection for BindInterface dropdown
  • Complete SSH command generation for all new fields
  • Multi-value field handling in parser and writer
  • Refactored mapKVToServer to reduce cyclomatic complexity (40 → 8)
  • Form-level keyboard shortcut handling to avoid input conflicts
  • Backwards compatible - existing configs work without modification

Implementation Details

The implementation follows a systematic approach:

  1. Domain Model Extension: Added fields organized by functional category
  2. Parser Updates: Enhanced SSH config file parser to handle all new fields
  3. CRUD Operations: Updated create/update operations with proper field mapping
  4. UI Form Enhancement: Complete redesign with tabbed interface
  5. Command Builder: Refactored and extended for all new options with native flag preference
  6. Code Quality: Reduced complexity through function decomposition

Testing

  • Manual testing of all new fields in edit form
  • Verified SSH command generation with various combinations
  • Tested parsing existing SSH configs with these fields
  • Confirmed multi-value fields work correctly
  • Validated all dropdown options match SSH specifications
  • Tested keyboard navigation and shortcuts
  • Verified clickable tab navigation
  • Tested network interface auto-detection
  • Passed all golangci-lint checks

Use Cases

This update enables common SSH workflows:

  • Port forwarding: Database tunnels, web service access
  • Connection multiplexing: Faster subsequent connections
  • X11 forwarding: Remote GUI applications
  • Advanced security: Custom ciphers, MACs, and key exchange algorithms
  • Network binding: Specify source address/interface for multi-homed systems
  • Automated scripts: BatchMode and LocalCommand support
  • Enhanced authentication: Fine-grained control over auth methods
  • Better UX: Organized tabbed interface for complex configurations

Breaking Changes

None. All changes are backwards compatible.

Screenshots

The edit form now features a tabbed interface with 6 organized sections:

  • Basic - Core server configuration
  • Connection - Proxy, bind options, and connection settings
  • Forwarding - Port, X11, and agent forwarding
  • Authentication - Key management and auth methods
  • Multiplexing - Connection sharing configuration
  • Advanced - Security, cryptography, environment, and debugging

Closes #46

Adembc and others added 28 commits August 13, 2025 10:33
…aged fields, comments, and directives (Adembc#45)

This PR introduces a major refactor of the SSH config parsing and writing logic. The new implementation is more robust and secure, ensuring that only the intended changes are applied while preserving the original file’s structure.

Key changes

- Lossless parsing/writing: Preserve unmanaged fields (e.g., `ProxyJump`), comments, and directives such as `Include` and `Match`.

- Library update: Switched to [github.com/kevinburke/ssh_config](https://github.com/kevinburke/ssh_config)
 as the base parser, with a custom fork to support required modifications https://github.com/adembc/ssh_config.

- Backup policy: Before any modification, create a backup of the SSH config file. Maintain up to 10 backups (configurable in the future) and automatically delete older ones.

- IdentityFile handling: Parse IdentityFile as an array instead of a single string, with improved update logic.

- Bug fix: Resolve issue where tags could not be fully removed.

- Multiple aliases: Support defining and managing multiple aliases for a single server.

- Testability: Code has been refactored with testability in mind. Follow-up PRs will include dedicated tests.
Add comprehensive support for commonly used SSH configuration options:

Connection and proxy settings:
- ProxyJump: Jump host configuration
- ProxyCommand: Custom proxy command
- RemoteCommand: Execute command on remote host
- RequestTTY: TTY allocation control

Authentication settings:
- PubkeyAuthentication: Enable/disable public key auth
- PasswordAuthentication: Enable/disable password auth
- PreferredAuthentications: Authentication method preference

Agent and forwarding:
- ForwardAgent: SSH agent forwarding

Connection reliability:
- ServerAliveInterval: Keep-alive interval
- ServerAliveCountMax: Max keep-alive count
- Compression: Enable/disable compression

Security settings:
- StrictHostKeyChecking: Host key verification mode
- UserKnownHostsFile: Custom known_hosts file
- HostKeyAlgorithms: Preferred host key algorithms

Debugging:
- LogLevel: SSH client log verbosity

All fields are properly organized by usage frequency and logical grouping
in both the UI forms and server details view. The SSH config parser and
writer have been updated to handle these fields while preserving existing
formatting and comments.
UI improvements:
- Add visual section headers for better field grouping
- Use white bold text for section headers
- Indent fields with 2 spaces for clear hierarchy
- Implement dynamic field lookup to handle mixed TextViews and InputFields

SSH config optimization:
- Skip default port 22 to reduce config clutter
- Group related fields together in logical sections
- Organize fields by usage frequency and relevance
- Maintain compact output without unnecessary blank lines

The form now provides better visual organization with clear sections:
Basic Configuration, Connection & Proxy, Authentication,
Agent & Forwarding, Connection Reliability, Security, and Debugging.
Update BuildSSHCommand to generate complete SSH commands with all supported options:

Proxy and connection options:
- ProxyJump (-J flag)
- ProxyCommand (-o option)
- RemoteCommand (appended after host)

Authentication options:
- PubkeyAuthentication
- PasswordAuthentication
- PreferredAuthentications

Agent and forwarding:
- ForwardAgent (-A/-a flags)

Connection reliability:
- ServerAliveInterval
- ServerAliveCountMax
- Compression (-C flag)

Security options:
- StrictHostKeyChecking
- UserKnownHostsFile
- HostKeyAlgorithms

TTY and logging:
- RequestTTY (-t/-T/-tt flags)
- LogLevel (-q/-v/-vv/-vvv flags)

Enhanced features:
- Support multiple identity files (all included with -i)
- Proper command ordering (options, host, remote command)
- Quote values with spaces automatically

This ensures copied SSH commands include all configured options,
making them functionally equivalent to using ssh with the config file.
Refactor to fix linting issues:
- Extract SSH option constants to reduce string duplication
- Split BuildSSHCommand into smaller focused functions
- Reduce cyclomatic complexity from 34 to acceptable levels

Improvements:
- Add support for RequestTTY=auto (SSH default behavior)
- Add fallback for unknown RequestTTY values via -o option
- Update form hint to show all valid options (yes/no/force/auto)

Code organization:
- addProxyOptions(): ProxyJump, ProxyCommand
- addAuthOptions(): Authentication and ForwardAgent
- addConnectionOptions(): ServerAlive settings, Compression
- addSecurityOptions(): HostKey and known_hosts settings
- addTTYAndLoggingOptions(): RequestTTY and LogLevel

All SSH config fields and command-line mappings verified against
SSH manual pages for correctness.
- Convert yes/no fields to dropdowns: ForwardAgent, Compression, PubkeyAuthentication, PasswordAuthentication
- Convert RequestTTY to dropdown with yes/no/force/auto options
- Convert StrictHostKeyChecking to dropdown with yes/no/ask/accept-new options
- Convert LogLevel to dropdown with QUIET/FATAL/ERROR/INFO/VERBOSE/DEBUG levels
- Add findOptionIndex helper for case-insensitive option matching
- Add getDropdownValue helper to extract dropdown selections
- Display 'seconds' unit in ServerAliveInterval field label
- All dropdowns default to empty (no selection) when not set
- Add 20+ new SSH config fields organized by category
- Connection & proxy: ConnectTimeout, ConnectionAttempts
- Port forwarding: LocalForward, RemoteForward, DynamicForward
- Authentication: IdentitiesOnly, AddKeysToAgent, IdentityAgent
- X11 forwarding: ForwardX11, ForwardX11Trusted
- Connection multiplexing: ControlMaster, ControlPath, ControlPersist
- Reliability: TCPKeepAlive
- Command execution: LocalCommand, PermitLocalCommand
- Environment: SendEnv, SetEnv
- Debugging: BatchMode

UI improvements:
- Reorganize form fields into logical groups
- Add dropdowns for enumerated values
- Support comma-separated multi-value fields
- Visual section headers with proper indentation

SSH command generation:
- Support all new fields in copy SSH command
- Proper flag mapping for all options
- Handle multi-value fields correctly
- Split mapKVToServer into 8 specialized mapping functions
- Group related SSH config fields by category
- Each function handles a specific category of config fields
- Reduces cyclomatic complexity from 40 to under 10 per function
@tan9 tan9 changed the title feat: add 15+ SSH config fields with grouped form interface feat: add 20+ SSH config fields with grouped form interface Sep 11, 2025
…avigation

- Restructure ServerForm to use tabbed interface with Pages
- Add Basic, Connection, Forwarding, Authentication, Multiplexing, and Advanced tabs
- Implement tab navigation with Ctrl+L/Ctrl+H shortcuts
- Add visual tab bar with current tab highlighting
- Organize SSH config options into logical groups
- Improve form layout and user experience

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Adembc Adembc self-requested a review September 12, 2025 07:30
@Adembc
Copy link
Owner

Adembc commented Sep 12, 2025

Thanks for this PR @tan9 , it looks amazing! I’m reviewing it now and will merge it ASAP.

@tan9
Copy link
Author

tan9 commented Sep 13, 2025

Hi @Adembc, I’ve added commit d4de629 to consolidate the Multiplexing settings under the Connection tab.

@tan9
Copy link
Author

tan9 commented Sep 13, 2025

Update: Enhanced SSH Configuration Support

Recent Changes

1. Added PubkeyAcceptedAlgorithms Support

In response to #10, I've added support for the PubkeyAcceptedAlgorithms field (the modern replacement for the deprecated PubkeyAcceptedKeyTypes):

  • ✅ Added PubkeyAcceptedAlgorithms field to the domain model
  • ✅ Positioned right after PubkeyAuthentication in the Authentication tab for logical grouping
  • ✅ Supports both the new name (PubkeyAcceptedAlgorithms) and legacy name (PubkeyAcceptedKeyTypes) when reading SSH configs for backward compatibility
  • ✅ Writes using the modern PubkeyAcceptedAlgorithms name
  • ✅ Included in Copy SSH command generation with -o flag

2. Advanced Algorithm Configuration with Autocomplete

Significantly improved the user experience for configuring SSH algorithms:

  • Smart Input Fields: Converted algorithm fields from simple dropdowns to intelligent input fields supporting OpenSSH's advanced syntax:

    • +algorithm - Append to defaults
    • -algorithm - Remove from defaults
    • ^algorithm - Prepend to defaults
    • algorithm1,algorithm2 - Multiple algorithms
  • Autocomplete/Typeahead: All algorithm fields now feature:

    • Tab-triggered autocomplete with comprehensive algorithm suggestions
    • Prefix-aware suggestions (works with +, -, ^)
    • Support for comma-separated multiple values
    • Case-insensitive matching
  • Affected Fields:

    • PubkeyAcceptedAlgorithms - Public key algorithms
    • Ciphers - Encryption algorithms
    • MACs - Message authentication codes
    • KexAlgorithms - Key exchange algorithms
    • HostKeyAlgorithms - Host key algorithms

Why These Changes Matter

  1. Addresses User Request: Directly implements the PubkeyAcceptedAlgorithms field requested in Support for ProxyJump? #10
  2. Modern SSH Standards: Uses the current OpenSSH naming conventions while maintaining backward compatibility
  3. Enhanced Usability: The autocomplete feature makes it much easier to configure complex algorithm settings without memorizing exact algorithm names
  4. Flexibility: Supports OpenSSH's powerful prefix syntax for fine-tuning algorithm preferences

Testing

  • ✅ All changes compile successfully
  • ✅ Passes golangci-lint checks
  • ✅ Backward compatibility maintained for existing configs

These enhancements make LazySSH more powerful for users who need fine-grained control over their SSH security configurations while keeping the interface intuitive.

@tan9 tan9 force-pushed the feat/support-more-ssh-config-property branch 2 times, most recently from 6b93a3f to 76b152a Compare September 13, 2025 03:54
- Move ControlMaster, ControlPath, and ControlPersist fields to Connection tab
- Remove standalone Multiplexing tab to simplify interface (6 tabs -> 5 tabs)
- Group multiplexing options under yellow "Multiplexing" header in Connection tab
- Better organization by keeping all connection-related settings together
- Add PubkeyAcceptedAlgorithms field to domain model (modern name, replaces deprecated PubkeyAcceptedKeyTypes)
- Implement dropdown in Authentication tab with common key algorithms (Ed25519, ECDSA, RSA, etc.)
- Position field right after PubkeyAuthentication for logical grouping
- Support both new (PubkeyAcceptedAlgorithms) and legacy (PubkeyAcceptedKeyTypes) names in SSH config
- Include in Copy SSH command generation with -o flag
- Convert algorithm fields to input fields with prefix support (+append, -remove, ^prepend)
- Add intelligent autocomplete/typeahead for all algorithm fields:
  * PubkeyAcceptedAlgorithms (public key algorithms)
  * Ciphers (encryption algorithms)
  * MACs (message authentication codes)
  * KexAlgorithms (key exchange algorithms)
  * HostKeyAlgorithms (host key algorithms)
- Support comma-separated multiple values with autocomplete for each segment
- Handle prefix characters (+, -, ^) correctly in autocomplete suggestions
- Display helpful hints for syntax and Tab key usage
- Include comprehensive algorithm lists for each field type

This makes it much easier for users to configure complex SSH algorithm settings
without having to remember exact algorithm names.
- Move PubkeyAcceptedAlgorithms from Authentication tab to Advanced tab's Cryptography section
- Position after HostKeyAlgorithms for better logical grouping with other algorithm fields
- Update all related data structures (ServerFormData, getDefaultValues, getFormData, dataToServer) to reflect new position
- Maintain autocomplete functionality and prefix syntax support (+, -, ^)

This change groups all cryptographic algorithm settings together in the Advanced tab,
making it easier for advanced users to find and configure all security-related algorithms
in one place. The Authentication tab now focuses on authentication methods and basic options.
- Implement smart Tab key behavior that navigates to next field when empty
- Only trigger autocomplete when there's actual input to complete
- Simplify cryptography hint text to save screen space
- Return nil from autocomplete when no matches to allow Tab navigation

This resolves the Tab key conflict between field navigation and autocomplete
selection, providing a more intuitive user experience.
- Add HostbasedAcceptedAlgorithms field to domain model
- Support deprecated aliases: HostbasedKeyTypes, HostbasedAcceptedKeyTypes
- Add clear comments documenting which options are deprecated since OpenSSH 8.5
- Update mapper, CRUD operations, and SSH command builder accordingly

This ensures backward compatibility with older SSH configurations while
supporting the newer, more accurate naming conventions introduced in OpenSSH 8.5.
- Add HostbasedAcceptedAlgorithms input field in Advanced tab
- Include autocomplete support with algorithm suggestions
- Position field after PubkeyAcceptedAlgorithms in Cryptography section
- Update form data structures to handle the new field

This completes the UI support for hostbased authentication algorithm
configuration alongside the existing backend support.
- Add all newly supported SSH config fields to details view
- Create extensible structure with logical field grouping
- Maintain clean display without group labels for clarity
- Apply consistent 2-space indentation throughout
- Include fields: ConnectTimeout, ConnectionAttempts, TCPKeepAlive,
  IdentitiesOnly, AddKeysToAgent, IdentityAgent, ForwardX11,
  ForwardX11Trusted, port forwarding options, environment settings,
  PubkeyAcceptedAlgorithms, HostbasedAcceptedAlgorithms, etc.

This provides a comprehensive view of all SSH configuration while
maintaining a clean, organized display that's easy to extend.
@tan9 tan9 force-pushed the feat/support-more-ssh-config-property branch from 76b152a to f64bcac Compare September 13, 2025 04:16
tan9 added 10 commits September 13, 2025 12:23
- Replace prefix matching with sequential character matching
- Allows typing "ct" to match "aes128-ctr", "aes256-ctr", etc.
- Typing "3c" matches "3des-cbc", "256gcm" matches "aes256-gcm@openssh.com"
- Provides more intelligent filtering for long algorithm lists

This makes it much easier to find specific algorithms by typing just
a few key characters that appear in sequence within the algorithm name.
…rrectly

This commit improves the UX for SSH configuration by:

1. Display SSH defaults in dropdown options as "default (value)"
   - Users can now see what SSH will use if they don't specify a value
   - Makes it clear when they're overriding defaults vs using them

2. Fix logic error when switching back to default values
   - Add removeKVNode function to delete config entries when user selects default
   - Update logic to remove fields when empty (default selected) instead of keeping old values
   - Handle Port field specially to remove when set to default (22)
   - Preserve unknown SSH config fields during updates

3. Add comprehensive SSH defaults map covering:
   - Connection settings (Port, TCPKeepAlive, Compression, etc.)
   - Authentication (PubkeyAuthentication, PasswordAuthentication, etc.)
   - Forwarding (ForwardAgent, ForwardX11, etc.)
   - Multiplexing (ControlMaster, ControlPath, etc.)
   - Security and debugging options

This ensures users have better visibility into SSH behavior and can cleanly reset values to defaults.
…ter UX

- Replace "(comma)" suffix with placeholder text showing actual examples:
  * Keys: "e.g., ~/.ssh/id_rsa, ~/.ssh/id_ed25519"
  * Tags: "comma-separated tags"
  * LocalForward: "e.g., 8080:localhost:80, 3000:localhost:3000"
  * RemoteForward: "e.g., 80:localhost:8080"
  * DynamicForward: "e.g., 1080, 1081"
  * SendEnv: "e.g., LANG, LC_*, TERM"
  * SetEnv: "e.g., FOO=bar, DEBUG=1"

- Replace "(seconds)" suffix with placeholder "seconds":
  * ConnectTimeout
  * ServerAliveInterval

- Convert InputField creation to use tview.NewInputField() for placeholder support
- Update getFormData() to use correct field labels with colons
- Make UI more consistent and intuitive by showing examples instead of format hints
…cuts

- Show confirmation dialog when exiting form with unsaved changes
- Add keyboard shortcuts (S)ave, (D)iscard, (C)ancel for quick navigation
- Implement smart change detection using reflection to compare all fields
- Skip metadata fields (LastSeen, PinnedAt, SSHCount) in change detection
- Preserve metadata fields when saving to avoid data loss
- Handle nil vs empty slice differences correctly
- Simplify LogLevel handling to use uppercase values per SSH spec
- Return boolean from handleSave() to indicate success/failure
- Show form with error message when validation fails from modal
- Add handleSaveWrapper() for button callbacks
- Ensure users see validation errors instead of silent failure
…reen style

- Remove verbose shortcut hints from title bar
- Add clean hint bar at bottom with consistent format
- Use ^H/^L notation to match main screen convention
- Improve visual consistency across UI components
- Move hint bar to screen bottom similar to main screen's status bar layout
- Apply same background color (tcell.Color235) as main screen's status bar
- Add white color highlighting to keyboard shortcuts in hint text
- Separate form panel from hint bar for better visual hierarchy

The hint bar now appears at the very bottom of the screen with a darker
background, outside the form panel border, providing a consistent UI
experience with the main screen.
- Add header field to ServerForm struct with version and commit info
- Implement SetVersionInfo method to configure header version data
- Update handlers to pass version/commit info when creating server forms
- Reorganize layout: header at top, form panel in middle, hint bar at bottom
- Fix build order to ensure version info is set before creating header
- Ensure visual consistency with main screen by displaying app header
…ontainer

When validation fails after clicking Save from the confirmation modal,
the error message is now correctly displayed in the form panel's title bar
(which has a border) rather than the root container title.
Prevent accidental commits of the compiled binary
@tan9 tan9 force-pushed the feat/support-more-ssh-config-property branch from 7297f04 to 8c2d33d Compare September 13, 2025 08:46
@tan9 tan9 closed this Sep 13, 2025
@tan9 tan9 force-pushed the feat/support-more-ssh-config-property branch from 8c2d33d to 8031a03 Compare September 13, 2025 09:42
@tan9
Copy link
Author

tan9 commented Sep 13, 2025

Hi @Adembc, I accidentally closed this pull request—please check out #50 for the updated one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for more SSH config fields
3 participants