Skip to navigation

Experimental. For evaluation. Interfaces, configuration, and behavior may change incompatibly.

Executes remote commands and transfers files through native SSH or Teleport.

Prerequisites

  • Reachable SSH hosts and an authorized login. For managed Bash commands, the login user must belong to group_name on each target host. The default is maestro-svc-users and the group must already exist.
  • Worker-readable private key and trusted known_hosts file.

Setup

  • Configure native SSH:
[modules.ssh]
user = "automation"
use_teleport = false
use_teleport_direct = false
[modules.ssh.client_options.default]
identity_file = "/etc/ssh/automation_key"
known_hosts_file = "/etc/ssh/known_hosts"
  • Create maestro-svc-users and add the login user, or set group_name to an existing group the user belongs to.

This module must be enabled in your Remediation Orchestrator config before it is available to scripts.

This module provides functionality for executing commands over SSH. It supports authentication via ssh-agent, private key (with optional passphrase), or password. Host key verification can be done using a known_hosts file or disabled (not recommended for untrusted networks).

Members

bash

ssh.bash(host, script, cluster_id?, env?, connection_strategy?, client_options_name?, timeout?, keep_descendants_alive?, node_id?)

Execute a bash script (one-liner or multi-line) over SSH on the specified node. The script is passed via stdin to ‘bash -s’. Returns an ExecuteResult.

Parameters
hoststringThe target host (hostname or IP address) to execute the script on.
scriptstringThe Bash script string to execute.
cluster_id?optionalstringThe cluster ID of the target host.
env?optionaldict[string:string]A dict of environment variables (string:string) to set for the script.
connection_strategy?optionalstringThe connection strategy to use for the SSH connection. Either ‘native’ or ‘teleport’. If not provided, the strategy is determined by modules.ssh.use_teleport, falling back to the ‘ssh_use_teleport’ feature flag when the setting is absent. Set this explicitly when a workflow needs to override that default.
client_options_name?optionalstringThe name of the client options to use for the SSH connection. If not provided, the default client options are used.
timeout?optionalstringTimeout duration as a string (e.g. ‘2m’, ’30s’, ‘1h’). If not provided, no user timeout is applied. Instead, Temporal will timeout the activity based on the default timeout policy.
keep_descendants_alive?optionalboolIf true, only kill the wrapper processes (nohup, sg, sh, bash) on timeout, leaving spawned descendant processes running. If false (default), kill all descendants.
node_id?optionalstringOptional node-registry identity used to resolve the transport host.
Returns
resultssh.ExecuteResultAn ExecuteResult object containing stdout, stderr, and exit_code.

execute

ssh.execute(host, command, cluster_id?, env?, stdin?, node_id?, activity_timeout?, maximum_attempts?)

Execute a command over SSH on the specified host. Returns an ExecuteResult.

Parameters
hoststringThe target host (hostname or IP address) for the SSH command.
commandstringThe command string to execute.
cluster_id?optionalstringThe cluster ID of the target host.
env?optionaldict[string:string]A dict of environment variables (string:string) to set for the command.
stdin?optionalstringOptional string content to pass to the command’s standard input.
node_id?optionalstringOptional node-registry identity used to resolve the transport host.
activity_timeout?optionalstringOptional per-call Temporal activity budget such as 31m. Both start-to-close and schedule-to-close use this value.
maximum_attempts?optionalintOptional maximum Temporal activity attempts. Zero preserves the SSH module default; one disables retries.
Returns
resultssh.ExecuteResultAn ExecuteResult object containing stdout, stderr, and exit_code.

write_file

ssh.write_file(host, path, file, cluster_id?)

Write a file to a remote host via SFTP. Creates parent directories if needed.

Parameters
hoststringThe target host (hostname or IP address) to write the file to.
pathstringThe destination path on the remote host.
filescriptrt.FileThe File object to transfer.
cluster_id?optionalstringThe cluster ID of the target host.
Returns
bytes_writtenintNumber of bytes written to the remote file.