parasite

SSH Operations

The client supports three remote management operations over SSH: install, connect, and shutdown. All use sshpass with password passed via environment variable.

All remote scripts are stored as templates in parasite-core/scripts/ with Unix (bash) and Windows (PowerShell) variants, parameterized at runtime via parasite_core::scripts module with config values.

Install Agent

Installs the parasite-agent binary on a remote server.

Flow:

  1. Scan local network for devices (configurable timeout via config.network.network_scan_timeout_ms)
  2. User selects a device or enters credentials manually
  3. SSH into the remote server
  4. Run install script (scripts/unix/install.sh or scripts/windows/install.ps1)
  5. Configure systemd/Windows service

Files: install.rs, app/dispatch/operations.rs, parasite-core/scripts/

SSH Connect

Connects to a remote server via SSH, starts the agent if needed, and establishes a TLS connection.

Flow:

  1. Scan local network for devices or enter credentials manually
  2. SSH into the remote server
  3. Run connect script (scripts/unix/connect.sh or scripts/windows/connect.ps1)
  4. Script starts agent via systemd/service or nohup fallback
  5. Parse the auth token from script output
  6. Auto-connect to the agent over TLS

Files: connect.rs, app/dispatch/operations.rs, parasite-core/scripts/

Shutdown Agent

Stops the agent on a remote server.

Flow:

  1. SSH into the remote server
  2. Run shutdown script (scripts/unix/shutdown.sh or scripts/windows/shutdown.ps1)
  3. Script stops agent via systemd/service or kill fallback
  4. Report success/failure

Files: shutdown.rs, app/dispatch/operations.rs, parasite-core/scripts/

Editor Sync (Mutagen)

Opens a local editor with bidirectional file sync via Mutagen.

Flow:

  1. Verify mutagen CLI is available
  2. Resolve remote home directory via SSH
  3. Start SSH ControlMaster (persistent connection)
  4. Inject SSH config for the host
  5. Create Mutagen sync session (remote → local workspace)
  6. Wait for initial sync to complete
  7. Spawn local editor PTY

Cleanup:

Files: editor/sync.rs, editor/control_master.rs, editor/ssh_config.rs, editor/workspace.rs

VS Code Integration

Launches VS Code with Remote-SSH connected to the agent.

Flow:

  1. Verify code CLI is available
  2. Resolve remote home directory via SSH
  3. Start SSH ControlMaster
  4. Inject SSH config for VS Code Remote-SSH
  5. Launch code --remote ssh-remote+host /path

Cleanup:

Files: code.rs, app/dispatch/code.rs

SSH Config Injection

The editor and code features inject temporary SSH config blocks:

# PARASITE-AUTO-<hash>
Host parasite-<hash>
    HostName <host>
    Port <port>
    User <user>
    ControlMaster no
    ControlPath ~/.parasite/sockets/ctrl-<hash>
    StrictHostKeyChecking accept-new
    UserKnownHostsFile ~/.parasite/known_hosts
# PARASITE-AUTO-END-<hash>

These blocks are automatically removed during cleanup.