Trebejo.SSH (Trebejo v1.0.0)

Copy Markdown View Source

SSH wrapper for remote command execution and file transfer.

Wraps the ssh and scp system binaries. For richer SSH support (key management, interactive sessions, etc.) consider a dedicated library like :ssh or :erlexec.

All command execution is routed through Arrea.Command.execute/2 with validate: false. Arguments are shell-quoted before being joined into the final command line so user/host/command values containing whitespace or shell metacharacters are safe.

Summary

Functions

Executes a command on a remote host via SSH.

Copies a local file to a remote host via SCP.

Functions

exec(host, command, opts \\ [])

@spec exec(String.t(), String.t(), keyword()) :: {:ok, String.t()} | {:error, term()}

Executes a command on a remote host via SSH.

Returns {:ok, output} on success or {:error, reason} on failure.

Options

  • :user — SSH user (default: root)
  • :port — SSH port (default: 22)
  • :identity — path to private key (default: system default)

scp(local, remote_host, remote_path, opts \\ [])

@spec scp(String.t(), String.t(), String.t(), keyword()) :: :ok | {:error, term()}

Copies a local file to a remote host via SCP.

Returns :ok on success or {:error, reason} on failure.