lazyssh

repository·main·Indexed 25 days ago

https://github.com/adembc/lazyssh

A terminal-based, interactive SSH manager for managing fleets of servers. It provides a keyboard-driven TUI to navigate, connect to, and configure servers defined in ~/.ssh/config, featuring fuzzy search, server pinning, and a tabbed interface for managing advanced OpenSSH options including proxy jumps, port forwarding, and security settings.

Tokens
1.9K
Snippets
3
Records
9
Agent score
85%

What's inside lazyssh

  1. Manage SSH servers with lazyssh

    main

    Lazyssh acts as a TUI wrapper for your ~/.ssh/config. It allows you to:

    • Read & Display: View servers from your existing ~/.ssh/config in a scrollable list.
    • Add/Edit: Use a tabbed interface to configure Host, user, port, keys, tags, Proxy settings, Port forwarding, and advanced security/cryptography settings.
    • Navigate: Use fuzzy search (by alias, IP, or tags) and one-keypress SSH connection via Enter.
    • Organize: Pin favorite servers to the top or sort by alias/last SSH.
    • Maintain: Ping servers to check status or delete entries safely.
  2. Install lazyssh via Binary Download

    main

    To install the latest binary for Darwin or Linux (amd64/arm64), use this script to fetch, extract, and move the binary to your PATH:

    # Detect latest version
    LATEST_TAG=$(curl -fsSL https://api.github.com/repos/Adembc/lazyssh/releases/latest | jq -r .tag_name)
    # Download the correct binary for your system
    curl -LJO "https://github.com/Adembc/lazyssh/releases/download/${LATEST_TAG}/lazyssh_$(uname)_$(uname -m).tar.gz"
    # Extract the binary
    tar -xzf lazyssh_$(uname)_$(uname -m).tar.gz
    # Move to /usr/local/bin or another directory in your PATH
    sudo mv lazyssh /usr/local/bin/
    # enjoy!
    lazyssh
  3. Build lazyssh from source

    main

    If you want to build the project from the source code, clone the repository and use make:

    # Clone the repository
    git clone https://github.com/adembc/lazyssh.git
    cd lazyssh
    
    # Build for macOS
    make build
    ./bin/lazyssh
    
    # Or Run it directly
    make run
  4. Launch the lazyssh TUI

    main
    To start the interactive terminal user interface (TUI) for managing and picking SSH servers, run the lazyssh binary. The application automatically detects your SSH configuration at ~/.ssh/config and manages metadata in ~/.lazyssh/metadata.json.
  5. Use lazyssh keyboard shortcuts

    main

    Lazyssh is a keyboard-driven TUI. Use the following shortcuts to navigate and manage your servers:

    Main Dashboard

    KeyAction
    /Toggle search bar
    ↑↓/jkNavigate servers
    EnterSSH into selected server
    cCopy SSH command to clipboard
    gPing selected server
    rRefresh background data
    aAdd server
    eEdit server
    tEdit tags
    dDelete server
    pPin/Unpin server
    sToggle sort field
    SReverse sort order
    qQuit

    Server Form (Add/Edit Mode)

    KeyAction
    Ctrl+HPrevious tab
    Ctrl+LNext tab
    Ctrl+SSave
    EscCancel
  6. Understand lazyssh config safety and backups

    main

    Lazyssh performs non-destructive edits to your ~/.ssh/config using a parser that preserves existing comments, spacing, and order. It uses atomic writes to minimize corruption risk.

    Backup Policy:

    • Original Backup: Before the first change, it creates ~/.ssh/config.original.backup. This is never overwritten.
    • Rolling Backups: Every subsequent save creates a timestamped backup (e.g., ~/.ssh/config-<timestamp>-lazyssh.backup). Lazyssh keeps a maximum of 10 recent backups and automatically rotates them.
  7. Reference SSH configuration fields in the Server struct

    main

    The Server struct supports a wide range of SSH configuration options. Below are the categorized fields available for configuration:

    Connection and Proxy

    • ProxyJump: Jump host for connection.
    • ProxyCommand: Command to use for proxying.
    • RemoteCommand: Command to execute on the remote host.
    • RequestTTY: Request a pseudo-terminal.
    • SessionType: none, subsystem, or default (OpenSSH 8.7+).
    • ConnectTimeout: Connection timeout string.
    • ConnectionAttempts: Number of connection attempts.
    • BindAddress / BindInterface: Local binding settings.
    • AddressFamily: any, inet, or inet6.
    • ExitOnForwardFailure: yes or no.
    • IPQoS: Quality of Service settings (e.g., af11, ef, lowdelay).

    Hostname Canonicalization

    • CanonicalizeHostname: yes, no, or always.
    • CanonicalDomains: Domains for canonicalization.
    • CanonicalizeFallbackLocal: yes or no.
    • CanonicalizeMaxDots: Maximum dots allowed.
    • CanonicalizePermittedCNAMEs: Permitted CNAMEs.

    Port Forwarding

    • LocalForward: Slice of local forwarding strings.
    • RemoteForward: Slice of remote forwarding strings.
    • DynamicForward: Slice of dynamic forwarding strings.
    • ClearAllForwardings: yes or no.
    • GatewayPorts: yes, no, or clientspecified.

    Authentication and Key Management

    • PubkeyAuthentication: Enable public key auth.
    • PubkeyAcceptedAlgorithms: Allowed public key algorithms.
    • HostbasedAcceptedAlgorithms: Allowed host-based algorithms.
    • IdentitiesOnly: yes or no.
    • AddKeysToAgent: SSH agent interaction.
    • IdentityAgent: Path to the identity agent.
    • PasswordAuthentication: Enable password auth.
    • KbdInteractiveAuthentication: yes or no.
    • NumberOfPasswordPrompts: Number of prompts.
    • PreferredAuthentications: List of preferred methods.

    Agent and X11 Forwarding

    • ForwardAgent: Enable agent forwarding.
    • ForwardX11: Enable X11 forwarding.
    • ForwardX11Trusted: Enable trusted X11 forwarding.

    Connection Multiplexing

    • ControlMaster: Enable master connection.
    • ControlPath: Path for the control socket.
    • ControlPersist: How long to persist the master connection.

    Connection Reliability

    • ServerAliveInterval: Interval for sending keepalives.
    • ServerAliveCountMax: Max keepalive failures.
    • Compression: Enable compression.
    • TCPKeepAlive: Enable TCP keepalives.
    • BatchMode: yes or no (disables interactive prompts).

    Security and Cryptography

    • StrictHostKeyChecking: Host key verification policy.
    • CheckHostIP: yes or no.
    • FingerprintHash: md5 or sha256.
    • UserKnownHostsFile: Path to known hosts file.
    • HostKeyAlgorithms: Allowed host key algorithms.
    • MACs: Allowed MAC algorithms.
    • Ciphers: Allowed ciphers.
    • KexAlgorithms: Allowed key exchange algorithms.
    • VerifyHostKeyDNS: yes, no, or ask.
    • UpdateHostKeys: yes, no, or ask.
    • HashKnownHosts: yes or no.
    • VisualHostKey: yes or no.

    Command Execution

    • LocalCommand: Command to run locally.
    • PermitLocalCommand: yes or no.
    • EscapeChar: Single character or "none.

    Environment and Debugging

    • SendEnv: List of environment variables to send.
    • SetEnv: List of environment variables to set.
    • LogLevel: Logging level (e.g., debug, info, error).
  8. Define a Server configuration using the Server struct

    main
    The Server struct is the primary data model for representing an SSH server connection. It includes basic connection details (Host, User, Port), metadata (Aliases, Tags, PinnedAt), and an extensive set of SSH configuration fields that map to standard OpenSSH options. This includes settings for proxy jumps, port forwarding, authentication methods, connection multiplexing, and security/cryptography.