Provides SSH connectivity for executing commands, transferring files, and gathering host information on remote systems. Since blocks cannot maintain long-lived connections, each operation establishes a connection, performs its task, and disconnects.
The app config contains SSH connection credentials that are shared across all blocks.
privateKey
(string, required): SSH private key for authenticationusername
(string, optional): Default SSH usernameknownHosts
(object, optional): Object mapping hostnames to their public keys for host verification. If not provided, host key verification is skipped (less secure but simpler for dynamic environments)
No HTTP endpoints or timers needed for the SSH app.
- Description: Executes a single command on a remote host via SSH
- Input Config:
host
(string, required): Hostname or IP address to connect toport
(number, required): SSH port for this connection (defaults to 22)command
(string, required): The command to executeusername
(string, optional): Override the default SSH username for this connectionworkingDirectory
(string, optional): Working directory for the command
- Output:
stdout
(string): Standard output from the commandstderr
(string): Standard error from the commandexitCode
(number): Exit code of the commandduration
(number): Execution time in milliseconds
- Description: Uploads a script to a temporary location and executes it on the remote host
- Input Config:
host
(string, required): Hostname or IP address to connect toport
(number, required): SSH port for this connection (defaults to 22)script
(string, required): The script content to executeusername
(string, optional): Override the default SSH username for this connectioninterpreter
(string, optional): Script interpreter (defaults to "sh")workingDirectory
(string, optional): Working directory for script execution
- Output:
stdout
(string): Standard output from the scriptstderr
(string): Standard error from the scriptexitCode
(number): Exit code of the scriptduration
(number): Execution time in milliseconds
- Description: Uploads a file to the remote host via SCP/SFTP
- Input Config:
host
(string, required): Hostname or IP address to connect toport
(number, required): SSH port for this connection (defaults to 22)content
(string, required): File content (base64 encoded for binary, plain text for text files)destinationPath
(string, required): Full path where to save the fileusername
(string, optional): Override the default SSH username for this connectionencoding
(string, optional): "base64" or "text" (defaults to "text")permissions
(string, optional): File permissions in octal format (e.g., "0644")
- Output:
path
(string): The destination path where file was uploadedsize
(number): Size of the uploaded file in bytes
- Description: Downloads a file from the remote host via SCP/SFTP
- Input Config:
host
(string, required): Hostname or IP address to connect toport
(number, required): SSH port for this connection (defaults to 22)sourcePath
(string, required): Full path of the file to downloadusername
(string, optional): Override the default SSH username for this connectionencoding
(string, optional): "base64" or "text" for output encoding (defaults to "base64")
- Output:
content
(string): File content (encoded according to input)path
(string): The source path that was downloadedsize
(number): File size in bytespermissions
(string): File permissions in octal formatmodifiedTime
(string): Last modified timestamp (ISO 8601 format)
- Description: Retrieves and exposes host metadata as signals
- Block Config (static):
host
(string, required): Hostname or IP address to connect toport
(number, required): SSH port for this connection (defaults to 22)username
(string, optional): Override the default SSH username for this connection
- Signals:
hostname
(string): The hostname of the remote systemosType
(string): Operating system type (e.g., "linux", "darwin")osRelease
(string): OS version/release informationarchitecture
(string): System architecture (e.g., "x86_64")uptime
(number): System uptime in secondsloadAverage
(object): Load average with 1, 5, and 15 minute valuesmemoryTotal
(number): Total memory in bytesmemoryFree
(number): Free memory in bytes
- Implementation: Uses
onSync
to gather metadata when the block is synced
Since blocks cannot maintain persistent connections, each operation should:
- Establish an SSH connection using the app-level credentials (or overridden username)
- Perform the requested operation
- Close the connection
- Return the results
If the app has no default username configured, and a block's config does not specify a username, the block callback should throw an error.
Host key verification should be handled according to the knownHosts
configuration - either verifying against provided keys or skipping verification if not configured.
- Make sure you have the Test Utils app installed.
- Create a temp directory for your test.
- Run
ssh-keygen -t rsa -b 4096 -f ./test_ssh_key -N ""
to get a test SSH key pair. - Assuming you have a local flows dev setup, run
docker run \
--rm \
--name ssh-test-server \
-p 2222:2222 \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Etc/UTC \
--network=spaceflows_default \
-e USER_NAME=testuser \
-e PASSWORD_ACCESS=false \
-e SUDO_ACCESS=true \
-e PUBLIC_KEY_FILE=/config/authorized_keys \
-v "$PWD/test_ssh_key.pub:/config/authorized_keys:ro" \
lscr.io/linuxserver/openssh-server:latest
- Run
docker network inspect spaceflows_default
and find the IP address of the SSH server container. - Create and install the SSH app. Set the private key file contents as the
privateKey
config, the username astestuser
. - Import the scenario, configure the IP address in the Variables block. Trigger blocks using debug events.