LyHug

ssh-xfer

Transfer or sync files between two SSH hosts with rsync. Use when the user asks to copy, push, pull, or mirror files or directories to a host reachable via an SSH Host alias, or to diagnose SSH/rsync transfer failures. Requires an explicit --host and explicit source/destination paths.

LyHug 0 Updated 3h ago

Resources

5
GitHub

Install

npx skillscat add lyhug/ssh-xfer

Install via the SkillsCat registry.

SKILL.md

ssh-xfer

ssh-xfer is a thin rsync over SSH wrapper for two hosts. It has no default host, no default transfer root, and no daemon. The caller supplies the SSH Host alias and exact paths.

Running the CLI

This skill bundles the CLI at scripts/ssh-xfer. It is not guaranteed to be on PATH. Run it by path, from this skill directory:

./scripts/ssh-xfer --host HOST doctor
# or use <skill-dir>/scripts/ssh-xfer from anywhere

If ssh-xfer is already on PATH, that is the same tool. Do not assume the bare command resolves.

Resolving HOST

HOST is an SSH Host alias in ~/.ssh/config, not an IP. This skill does not discover or guess it. If the user names a host, use it; otherwise read the Host entries in ~/.ssh/config and ask/confirm. SSH_XFER_HOST may provide a default. Never invent a host.

Global options (--host, --json, --dry-run, --quiet, --ssh-option) may appear before or after the subcommand.

Use it when the user wants to:

  • copy a file or directory from the current host to a peer host, or back;
  • mirror a directory with rsync;
  • check whether SSH/rsync between two hosts works.

Do not use it as a general-purpose remote shell. Do not invent a host or path.

Commands

scripts/ssh-xfer --host HOST doctor
scripts/ssh-xfer --host HOST doctor --path REMOTE_PATH
scripts/ssh-xfer --host HOST ls REMOTE_PATH
scripts/ssh-xfer --host HOST push LOCAL REMOTE
scripts/ssh-xfer --host HOST pull REMOTE LOCAL
scripts/ssh-xfer --host HOST sync SRC DST [--pull] [--delete --yes]
scripts/ssh-xfer --host HOST status

Add --json when the result will be parsed instead of read by a human. Add --dry-run to preview rsync without changing anything.

Operating rules

  1. Host must be explicit. If the user has not named an SSH Host alias, ask for it or inspect ~/.ssh/config; do not guess.
  2. Paths must be explicit. Do not silently substitute ~/ or a default directory. Preserve the user's trailing slash semantics.
  3. Run doctor first when the host is new, the network changed, or a transfer failed at connect time.
  4. --delete is destructive. Always run the command without --yes first, show the dry-run result, and only add --yes after the user confirms. Never add --yes on your own initiative.
  5. Do not transfer secrets by default. Avoid ~/.ssh, ~/.gnupg, ~/.aws, .env, *.pem, *.key, id_*, credential stores, and browser profiles unless the user explicitly asks for that exact path. Warn before doing so.
  6. No sudo. If the peer write fails on permissions, report the owner/mode and ask; do not wrap the transfer in sudo.
  7. Use status/logs on failure. scripts/ssh-xfer --host HOST status shows the last transfer; doctor separates SSH, rsync, disk, and path problems.

Path semantics

  • Current host: relative to the current shell directory, or absolute; ~ is expanded locally.
  • Peer host: relative to the peer $HOME, or absolute with /.
  • Source directory with a trailing slash means "contents"; without it means "the directory itself" (rsync semantics).

Reporting

  • On success: state direction, source, destination, and whether it was dry-run.
  • On failure: include the failing layer (SSH, rsync, disk, permission) and the relevant doctor or status line.
  • Never claim a destructive sync succeeded without checking the exit code.