Files
linux-connector/docs/plans/linux-connector/01-spec.md
T

6.7 KiB

Gate 1 — Spec & Product: linux-connector

1. Problem Statement & User Need

In modern Linux homelabs and enterprise clusters, engineers manage dozens of physical servers, Proxmox hypervisors, K3s Kubernetes nodes, storage appliances, and testing virtual machines. Two common daily workflows are currently fragmented across outdated legacy scripts:

  1. Interactive Host Access (previously psh.sh):
    • Operators jump between servers daily. Native OpenSSH ssh user@host requires memorizing IP addresses, ports, and hostnames.
    • The legacy psh script stored plain-text records in an ad-hoc tab-delimited file, enforced insecure file permissions (755), provided a clunky bash select menu, and completely ignored the user's existing ~/.ssh/config.
  2. Fleet/Cluster Command Execution (previously massAct.sh):
    • Running ad-hoc operational commands (e.g. checking disk space, inspecting kernel versions, restarting services, or querying linux-updater status) across multiple nodes simultaneously.
    • The legacy massAct.sh script grew into a 1,750-line monolithic shell script that relied on sshpass (storing/passing plaintext passwords), suffered from race conditions in background process tracking, and lacked clean live streaming output.

linux-connector unifies both operational needs into a fast, elegant CLI tool:

  • Interactive Launcher (linux-connector connect / default): Instantly parses ~/.ssh/config and homelab inventory, presents a fuzzy-searchable terminal menu with pre-flight reachability checks, and drops the operator into a full native interactive terminal.
  • Fleet Command Runner (linux-connector exec): Concurrently dispatches commands across targeted node groups, streams real-time color-coded terminal output, and displays an execution summary with exit codes and execution times.
  • Fleet Connectivity Matrix (linux-connector status): Rapidly scans homelab nodes to verify SSH port reachability, round-trip latency, and system availability.

2. Success Metrics

  1. Instant Interactive Launch: Launching linux-connector and selecting a host connects to SSH within 100ms of user selection.
  2. Native OpenSSH Compatibility: 100% interoperable with ~/.ssh/config—automatically inherits existing host aliases, ProxyJump bastions, custom identity keys, and SSH agent sessions with zero manual re-entry.
  3. Robust Concurrent Execution: Capable of running commands across 50+ remote nodes concurrently without process leaks or zombie processes.
  4. Live Prefixed Streaming: Streams output from remote nodes in real time with distinguishable colored host tags, followed by an actionable summary table.
  5. Zero-Friction Fallback: Features a pure ANSI terminal menu when fzf is absent, and seamlessly delegates to fzf if installed on the host.
  6. Enterprise Safety: Replaces sshpass anti-patterns with standard SSH key/agent authentication and secure agent forwarding.

3. User Stories & Announcement

Announcement

"Announcing linux-connector v1.0.0 — your single command center for Linux fleet connectivity. Jump into any homelab node with interactive fuzzy search (linux-connector), or execute fleet-wide commands in parallel (linux-connector exec -g k8s 'uptime'). Built for speed, full OpenSSH config interoperability, and live multi-node streaming."

User Stories

  • As a homelab administrator, I want to type linux-connector in my terminal, type 3 letters of a node's hostname, and immediately press Enter to open an SSH session without looking up IPs.
  • As a cluster engineer, I want to run linux-connector exec -g pve-cluster 'pvesm status' from my workstation, so that I can see the storage status across all Proxmox nodes simultaneously.
  • As a system operator, I want to run linux-connector exec -g all 'linux-updater check --json' to aggregate available package updates across my entire fleet into a single structured report.

4. Screens & CLI Commands

# 1. Interactive Host Launcher (Default / psh replacement):
$ linux-connector
? Select host to connect:
> pve-01.wired.intra      [192.168.10.11:22]  (tags: pve, hypervisor)  [ONLINE 1.2ms]
  pve-02.wired.intra      [192.168.10.12:22]  (tags: pve, hypervisor)  [ONLINE 1.4ms]
  k8s-master-01           [192.168.10.21:22]  (tags: k8s, control)     [ONLINE 2.1ms]
  k8s-worker-01           [192.168.10.31:22]  (tags: k8s, worker)      [ONLINE 1.9ms]
  nas.wired.intra         [192.168.10.2:22]   (tags: storage)          [ONLINE 0.8ms]
[Filter: k8s-                 ]
Connecting to root@192.168.10.21 (k8s-master-01)...

# 2. Parallel Command Execution (massAct replacement):
$ linux-connector exec -g k8s "uptime"
[INFO] Executing 'uptime' on 3 hosts (concurrency: 10)...
[k8s-master-01]  21:16:01 up 14 days,  3:12,  0 users,  load average: 0.12, 0.18, 0.15
[k8s-worker-01]  21:16:01 up 14 days,  3:11,  0 users,  load average: 0.45, 0.52, 0.49
[k8s-worker-02]  21:16:01 up 14 days,  3:10,  0 users,  load average: 0.38, 0.41, 0.40

============================= Execution Summary =============================
HOST            STATUS    EXIT CODE   DURATION
k8s-master-01   SUCCESS   0           0.28s
k8s-worker-01   SUCCESS   0           0.31s
k8s-worker-02   SUCCESS   0           0.30s
-----------------------------------------------------------------------------
Total: 3 hosts | Succeeded: 3 | Failed: 0 | Execution Time: 0.34s

# 3. Fleet Connectivity Matrix:
$ linux-connector status -g all
+-------------------+-----------------+-------+----------+---------------+
| HOST              | IP ADDRESS      | PORT  | STATUS   | LATENCY (ms)  |
+-------------------+-----------------+-------+----------+---------------+
| pve-01            | 192.168.10.11   | 22    | REACHABLE| 1.1 ms        |
| pve-02            | 192.168.10.12   | 22    | REACHABLE| 1.3 ms        |
| nas               | 192.168.10.2    | 22    | REACHABLE| 0.7 ms        |
| old-backup-vm     | 192.168.10.99   | 22    | TIMEOUT  | ---           |
+-------------------+-----------------+-------+----------+---------------+

# 4. SSH Tunnel Helper:
$ linux-connector tunnel pve-01 8006:localhost:8006
[INFO] Forwarding local port 8006 -> pve-01:8006 (Press Ctrl+C to terminate)

5. Scope & Constraints

  • Client Environments: macOS and Linux (Debian, Ubuntu, Fedora, RHEL, Arch).
  • Security: Strict Zero-Secrets policy. Passwords in plaintext files are forbidden. Authentication relies on SSH keys, SSH agent forwarding, or interactive prompt.
  • Terminal Discipline: Interactive session handover uses os.execvp("ssh", ...) so that raw terminal handling, TTY allocation, window resizing (SIGWINCH), and escape sequences remain 100% native to the operating system's OpenSSH client.