SSH Remote Command allows a connection with a SSH server to be established and that shell scripts to be executed.

Take a look at the configuration parameters of the component:

  • Account: for the component to make an authentication to a SFTP server, it’s necessary to use a BASIC or PRIVATE-KEY-type account. This parameter accepts Double Braces.

  • Username: must be used only when the account type is PRIVATE KEY.

  • Host: name of the host or IP address to make the connection. This parameter accepts Double Braces.

  • Port: number of the port - generally 22. This parameter accepts Double Braces.

  • Custom Environment Variables: if the option is enabled, you must inform the environment variables in a custom way in the Environment Variables field (eg: [{"key": "MYVAR", "value": "VAR_VALUE"}])

  • Environment Properties: name and value of the environment variables to be provided for the remote SSH server execution. These variables must be registered in sshd_config. Example of register in ssh_config: AcceptEnv MYVAR

  • Command: field used to specify the commands to be executed in the SSH server.

  • Ignore Output: if the option is enabled, the pipeline execution ignores the responses displayed in stdout or stderr in the SSH server. Otherwise, they’ll be displayed in the stdout and stderr fields of the component output.

  • Stdout As File: if the option is enabled, the stdout result answer will be recorded in a file. Otherwise, it’ll be displayed as a string in the component output.

  • Stdout File Name: name of the file to be created with the stdout information.

  • Stderr As File: if the option is enabled, the stderr result answer will be recorded in a file. Otherwise, it’ll be displayed as a string in the component output.

  • Stderr File Name: name of the file to be created with the stderr information.

  • Connection Timeout: expiration time of the connection with the server (in milliseconds).

  • Server Alive Interval: time the component will keep the connection active (in milliseconds).

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution continues, but the result will show a false value for the success property.

IMPORTANT: notice that some of the parameter above support Double Braces. To understand how this language works, read our article by clicking here.

Messages flow

Input

No specific input message is expected.

Output

When executing a SFTP component using the download, upload or move operations, the following JSON structure will be generated:

{
"stdout": "xpto",
"stderr": "xpto_err",
"stdoutFileName": "stdout.txt",
"stderrFileName": "stderr.txt",
"success": "true"
}
  • stdout: successful response of the script execution

  • stderr: response with errors of the script execution

  • stdoutFileName: file path saved with the information displayed in stdout. This property will be displayed only if the Stdout As File flag is enabled

  • stderrFileName: file path saved with the information displayed in stderr. This property will be displayed only if the Stderr As File flag is enabled

  • success: "true" if there’s been a connection and the script has been executed even if errors in stderr were returned

Output with error:

{
"success": false,
"message": "Could not execute the SSH remote command",
"error": "java.net.SocketTimeoutException: connect timed out"
}
  • success: “false” when the operation fails

  • message: message about the error

  • exception: information about the occurred error type

IMPORTANT: the file manipulation inside a pipeline occurs in a protected way. The files are available in a temporary directory that only the pipeline being executed has access to.

To better understand the messages flow in the Platform, click here and read our article.

SSH Remote Command in Action

  • Executing a script and receiving the information in the component JSON answer

Hostname: <HOST>

Port: <PORT>

Command: echo $MYNAME && echo error output >&2

Environment Variables: [{"key":"MYNAME", "value":"TEST"}]

Stdout As File: disabled

Stderr As File: disabled

Fail On Error: disabled

Result:

{
"stdout": "TEST",
"stderr": "error output",
"success": "true"
}

  • Executing a script and saving the information in files

Hostname: <HOST>

Port: <PORT>

Command: echo $MYNAME && echo error output >&2

Environment Variables: [{"key":"MYNAME", "value":"TEST"}]

Stdout As File: enabled

Stdout File Name: stdout.txt

Stderr As File: enabled

Stderr File Name: stderr.txt

Fail On Error: disabled

Result:

{
"stdoutFileName": "stdout.txt",
"stderrFileName": "stderr.txt",
"success": "true"
}
Did this answer your question?