Xamal.SSH (xamal v0.3.0)

Copy Markdown View Source

High-level SSH API for executing commands on remote hosts.

Provides on/2 and on_roles/3 for parallel execution across hosts. Uses Erlang's :ssh stdlib under the hood via ConnectionPool.

Summary

Functions

Execute a shell command string on a remote host. Returns {:ok, output} or {:error, reason}.

Execute a command list (as built by Commands modules) on a host. Joins the command parts into a single shell string.

Run a command interactively with a PTY (for IEx remote, bash, etc.). Connects local stdin/stdout to the remote session.

Execute a function on each host in parallel. Returns list of {host, result} tuples.

Execute on hosts grouped by role, with configurable parallelism.

Stream command output to stdout (for logs -f, etc.). Runs until the remote command exits or the process is interrupted.

Upload a file to a remote host via SCP (using SFTP channel).

Functions

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

Execute a shell command string on a remote host. Returns {:ok, output} or {:error, reason}.

execute_command(host, command_parts, opts \\ [])

Execute a command list (as built by Commands modules) on a host. Joins the command parts into a single shell string.

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

Run a command interactively with a PTY (for IEx remote, bash, etc.). Connects local stdin/stdout to the remote session.

on(hosts, fun)

Execute a function on each host in parallel. Returns list of {host, result} tuples.

on_roles(roles, config, fun, opts \\ [])

Execute on hosts grouped by role, with configurable parallelism.

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

Stream command output to stdout (for logs -f, etc.). Runs until the remote command exits or the process is interrupted.

upload(host, local_path, remote_path, opts \\ [])

Upload a file to a remote host via SCP (using SFTP channel).