SFTP, SCP und benannte Port-Forwards #32

Merged
Sebi merged 1 commits from feat/sftp-forwarding into main 2026-11-13 22:09:03 +00:00
Owner

Baut auf #31 auf (Basis feat/configure-all-options); nach dem Merge von #31 auf main umstellen.

SFTP & SCP

  • netssh sftp HOST[:PATH] und netssh scp SOURCE... TARGET mit derselben Hostauflösung wie ssh: Cache, Kurznamen/Rewrites, instance/host, Default-User/-Port, SSH-Optionen und Rules, --jump/--no-jump, --dry-run, Completion.
  • Eigene Flag-Tabellen pro Client: Port -P, -l = Bandbreite (User als -o User=), IPv6 in [...] bei host:path.
  • Pro scp-Aufruf nur ein NetBox-Host; extra_args und forwards gelten nur für ssh.

Port-Forwarding

  • ssh.forwards (global, pro Instanz, pro Rule; spezifischere Ebene ersetzt gleichnamige): web: {local: "8080:localhost:80"}, auch remote/dynamic.
  • netssh tunnel HOST NAME|SPEC... (ssh -N, ExitOnForwardFailure=yes) und netssh --forward NAME HOST; Specs wie 8080:localhost:80 gehen ohne Config.
  • Im Configurator editierbar („Port forwards“), Forward-Namen in der Completion.

TUI

  • Ctrl+O öffnet SFTP, Ctrl+T startet einen Tunnel mit konfigurierten oder Ad-hoc-Forwards.

Fix

  • Von netssh hinzugefügte Optionen landeten hinter -- (ssh las sie als Ziel); sie stehen jetzt vor dem ersten Operanden, was auch scp braucht.

Tests

  • go test ./... grün, neue Tests für Client-Flags, scp-Operanden, IPv6, Forwards, Tunnel, TUI-Tasten, Config, Wizard sowie Subprozess-Tests für sftp/scp/tunnel --dry-run und Completion.
  • Echt geprüft gegen einen temporären lokalen sshd: ssh, scp hoch/runter, sftp und ein Tunnel (HTTP-Abruf durch -L) über den Kurznamen.
  • TUI-Tasten nur per Unit-Test, nicht im echten Terminal.

🤖 Generated with Claude Code

Baut auf #31 auf (Basis `feat/configure-all-options`); nach dem Merge von #31 auf `main` umstellen. ## SFTP & SCP - `netssh sftp HOST[:PATH]` und `netssh scp SOURCE... TARGET` mit derselben Hostauflösung wie ssh: Cache, Kurznamen/Rewrites, `instance/host`, Default-User/-Port, SSH-Optionen und Rules, `--jump`/`--no-jump`, `--dry-run`, Completion. - Eigene Flag-Tabellen pro Client: Port `-P`, `-l` = Bandbreite (User als `-o User=`), IPv6 in `[...]` bei `host:path`. - Pro scp-Aufruf nur ein NetBox-Host; `extra_args` und `forwards` gelten nur für ssh. ## Port-Forwarding - `ssh.forwards` (global, pro Instanz, pro Rule; spezifischere Ebene ersetzt gleichnamige): `web: {local: "8080:localhost:80"}`, auch `remote`/`dynamic`. - `netssh tunnel HOST NAME|SPEC...` (ssh `-N`, `ExitOnForwardFailure=yes`) und `netssh --forward NAME HOST`; Specs wie `8080:localhost:80` gehen ohne Config. - Im Configurator editierbar („Port forwards“), Forward-Namen in der Completion. ## TUI - `Ctrl+O` öffnet SFTP, `Ctrl+T` startet einen Tunnel mit konfigurierten oder Ad-hoc-Forwards. ## Fix - Von netssh hinzugefügte Optionen landeten hinter `--` (ssh las sie als Ziel); sie stehen jetzt vor dem ersten Operanden, was auch scp braucht. ## Tests - `go test ./...` grün, neue Tests für Client-Flags, scp-Operanden, IPv6, Forwards, Tunnel, TUI-Tasten, Config, Wizard sowie Subprozess-Tests für `sftp`/`scp`/`tunnel --dry-run` und Completion. - Echt geprüft gegen einen temporären lokalen sshd: ssh, scp hoch/runter, sftp und ein Tunnel (HTTP-Abruf durch `-L`) über den Kurznamen. - TUI-Tasten nur per Unit-Test, nicht im echten Terminal. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sebi changed target branch from feat/configure-all-options to main 2026-11-13 22:06:58 +00:00
Sebi added 3 commits 2026-11-13 22:06:59 +00:00
After the NetBox instances, netssh configure now opens a menu with all
sections: SSH defaults, global SSH options (jump host, host key
checking, target, address family, extra args, -o options), SSH rules,
resolver & cache (including the cache file), shortcuts & command alias,
and completion.max_results. SSH options can also be set per instance.

The wizard rebuilt the config from its own fields, so re-running it
dropped global SSH options, ssh.rules and completion.max_results from
the file. It now edits a copy of the loaded config, and save validates
SSH options and rules before writing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shortcuts.rewrites applies regex replacements after the domain suffix
is stripped, e.g. ^([a-z]+)[0-9]+- -> $1 turns fsn1-bx1.hoster.de into
fsnbx1. The shortcut works for connecting (cached hosts), shell
aliases, and Tab completion, where it is offered when the full name
does not match the typed text. Rules are editable in netssh configure,
and netssh alias --test HOSTNAME shows a name's shortcut and the cached
hosts it matches.

The shortcut lookup only ran when domains or strip_hyphens were set;
it now also runs for rewrite-only configurations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add netssh sftp and netssh scp. Both resolve the host like a connection
does (cache, shortcuts and rewrites, instance/host, default user and
port, SSH options and rules, --jump/--no-jump, --dry-run) and get shell
completion. The per-client flag tables handle the differences from ssh:
the port is -P, -l is a bandwidth limit (the default user goes in as
-o User=), and IPv6 addresses are bracketed in host:path. All remote
scp operands must name the same host.

Add named port forwards under ssh.forwards (global, per instance, per
rule; a more specific layer replaces a forward of the same name),
netssh tunnel HOST NAME|SPEC... (ssh -N with ExitOnForwardFailure) and
netssh --forward NAME. Specs such as 8080:localhost:80 work without
configuration. Forwards are editable in netssh configure and completed
in the shell; the TUI opens SFTP with ctrl+o and a tunnel with ctrl+t.

Host resolution moves out of runSSHWrapper into resolveTarget, shared
by ssh, sftp, scp, tunnel, and the TUI.

Options added by netssh are now inserted before the first operand or
"--": after "--", ssh read them as the destination, and scp stops
reading options at the first operand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sebi merged commit 053db984be into main 2026-11-13 22:09:03 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Sebi/ssh-netbox-wrapper#32