Skip to content

SSH COMMAND - DATA SOURCE

Description

The SSH Command Data Source allows for the secure retrieval of data from remote servers using SSH (Secure Shell). This method is particularly useful for accessing data stored on servers that require authentication, ensuring that the data transfer is encrypted and secure.


Config

REQUIRED


Config Parameters

Name Description
host The hostname or IP address of the remote server. This is a required parameter.
dbUsername The username for authentication on the remote server. This is a required parameter.
dbPassword The password for authentication on the remote server. This is a required parameter.
key The SSH private key used for authentication. This is required parameter.
filePath The path to the file on the remote server that contains the data to be retrieved. This is a required parameter.
mimeType The MIME type of the data being retrieved. This is an optional parameter but can be useful for specifying the format of the data.

Config Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<apiroConf version="1" xmlns="http://apiro.com/apiro/v1/root">
    <loadOrder>10</loadOrder>
    <dataSources>
        <dataSource definition="SSH_COMMAND" execPriority="10" name="TEST_SSH_SOURCE">
            <config>
                <![CDATA[
                    {
                        "host":"my_host",
                        "dbUsername": "user",
                        "dbPassword": "pw",
                        "key": "{$SYS:MY_SFTP_KEY}",
                        "filePath":"my_file_path",
                        "mimeType":"application/octet-stream"
                    }
                ]]>
            </config>
        </dataSource>
    </dataSources>
</apiroConf>

Inline Feed Source

The SSH data source can be used inline within a dataFeed. The minimum output of an SSH source is:

  • outputStream
  • errorStream
  • exitCode

As seen below these are accessed by placing a preceding $. list path identifier.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    <dataFeeds>
        <dataFeed definition="EXPR_JSON_FEED2" name="SSH_COMTEST">
            <enabled>true</enabled>
            <push>false</push>
            <pull>true</pull>
            <schema>SSH_COMTEST</schema>
            <config><![CDATA[
{
  "dataSource": {
    "entity": "SSH_COMMAND",
    "config": {
      "host": "172.105.172.141",
      "key" : "${SYS:APIRO_SFTP_KEY}",
      "username" : "apirodrop",
      "command" : "rudtest/testscript.sh"
    }
  },
    "listPath": "$",
  "explicitMappings": [
    {
      "dictionary": "ID",
      "value": "#GRV{ java.util.UUID.randomUUID() }"
    },
    {
      "dictionary": "EXIT_CODE",
      "value": "#GRV{PAYLOAD.resolve('$.exitCode')}"
    },
    {
      "dictionary": "EXEC_MS",
      "value": "#GRV{PAYLOAD.resolve('$.execMs')}"
    },
    {
      "dictionary": "OUT_STREAM",
      "value": "#GRV{PAYLOAD.resolve('$.outputStream')}"
    },
        {
      "dictionary": "ERR_STREAM",
      "value": "#GRV{PAYLOAD.resolve('$.errorStream')}"
    },
  ]
}
]]></config>
        </dataFeed>
    </dataFeeds>

When an SSH source is used inline within a feed, the following parameters are used:

Name Description
host The hostname or IP address of the remote server. This is a required parameter.
key The SSH private key used for authentication. This is required parameter.
username The username for authentication on the remote server. This is a required parameter.
command The command to be run on the SSH server. This is a required parameter.

Common Mistakes

  • Incorrect Hostname or IP Address: Ensure that the host parameter is correctly specified.
  • Incorrect Authentication Details: Verify that the dbUsername and dbPassword are correct and have the necessary permissions on the remote server.
  • Incorrect SSH Key Path: If using an SSH key for authentication, ensure that the key parameter points to the correct path of the private key file.
  • Incorrect File Path: Confirm that the filePath parameter correctly points to the location of the data file on the remote server.
  • Incorrect MIME Type: If specifying a mimeType, ensure it accurately represents the format of the data being retrieved.