The SSH connector is used to execute commands on a remote host by means of the SSH protocol.

Features

  • Based on Standardized SSH2 Protocol
  • Password based authentication mechanism
  • SSH Key based authentication mechanism ( with or without passphrase )
  • Series of commands to be executed specified in simplified comma separated format
  • Shell Command Execution Types: shell and exec
  • Direct access to the command execution results from the remote server machine
  • Ability to set timeouts for connector execution
  • Synchronous / Asynchronous execution of the Connector

Connector Configuration

Configuration parameters- config(JSON)
ParameterDescriptionRequired
targetHost name or ip-address of the remote machine you wish to connect totrue: config/request
usernameUsername which will be used to log into remote machine, required for authenticationtrue: config/request
passwordPassword associated with the username specified, required for authenticationfalse: config/request
passphrasePassphrase that needs to be added to the SSH keyfalse: config/request
portPort to connect to on the remote machine. Default value is 22false: config/request
key-fileAbsolute file path including file name where the SSH key needs to be savedfalse: config/request
Example
{
  "target": "192.168.2.64",
  "username": "daniel",
  "password": "daniel123",
  "passphrase": "1234",
  "key-file": "/home/daniel/filename.pem",
  "port": "5000"
}

 

Actions

Password based Authentication

Password based authentication mechanism

Request parameters
ParameterDescriptionRequired
connector_nameName of the SSH Connector to be configuredtrue
targetHost name or ip-address of the remote machine you wish to connect totrue
usernameUsername which will be used to log into remote machine, required for authenticationtrue
passwordPassword associated with the username specified, required for authenticationtrue
commandCommand to be executed on the host server machinetrue
typeShell execution is of two types - shell and exec.
  • exec each command will be executed in a separate session as if the command is executed in new command shell
  • shell each command will be executed in the same session as if the command is executed in the same command shell
Default execution type is exec.
false
timeoutTimeout in milliseconds, taken by the connector to serve the ssh request. Default timeout is 60,000 msfalse
Response parameters
ParameterDescriptionRequired
resultResults as per the command executedtrue
Example
response=@call.connector("my-ssh-connector")
              .set("target","192.168.2.64")
              .set("username","daniel")
              .set("password","daniel123")
              .set("command","pwd")
              .set("timeout",1000)
              .sync

#SSH Connector Response Parameters
result=response.get("result")                    #Result

 

SSH key based authentication without Passphrase

SSH Key based authentication mechanism without passphrase

Request parameters
ParameterDescriptionRequired
connector_nameName of the SSH Connector to be configuredtrue
targetHost name or ip-address of the remote machine you wish to connect totrue
usernameUsername which will be used to log into remote machine, required for authenticationtrue
key-fileAbsolute file path including file name where the SSH key needs to be saved and resides on localtrue
commandCommand to be executed on the host server machinetrue
typeShell execution is of two types - shell and exec.
  • exec each command will be executed in a separate session as if the command is executed in new command shell
  • shell each command will be executed in the same session as if the command is executed in the same command shell
Default execution type is exec.
false
timeoutTimeout in milliseconds, taken by the connector to serve the ssh request. Default timeout is 60,000 msfalse
Response parameters
ParameterDescriptionRequired
resultResults as per the command executedtrue
Example
response=@call.connector("my-ssh-connector")
              .set("target","192.168.2.64")
              .set("username","daniel")
              .set("key-file":"/home/daniel/filename.pem")
              .set("command","pwd")
              .set("timeout",1000)
              .sync

#SSH Connector Response Parameters
result=response.get("result")                    #Result

 

SSH key based authentication with Passphrase

SSH Key based authentication mechanism with passphrase

Request parameters
ParameterDescriptionRequired
connector_nameName of the SSH Connector to be configuredtrue
targetHost name or ip-address of the remote machine you wish to connect totrue
usernameUsername which will be used to log into remote machine, required for authenticationtrue
passphrasePassphrase to be added to the key-filetrue
key-fileAbsolute file path including file name where the SSH key needs to be saved and resides on localtrue
commandCommand to be executed on the host server machinetrue
typeShell execution is of two types - shell and exec.
  • exec each command will be executed in a separate session as if the command is executed in new command shell
  • shell each command will be executed in the same session as if the command is executed in the same command shell
Default execution type is exec.
false
timeoutTimeout in milliseconds, taken by the connector to serve the ssh request. Default timeout is 60,000 msfalse
Response parameters
ParameterDescriptionRequired
resultResults as per the command executedtrue
Example 
response=@call.connector("my-ssh-connector")
              .set("target","192.168.2.64")
              .set("username","daniel")
              .set("passphrase", "daniel123")
              .set("key-file":"/home/daniel/filename.pem")
              .set("command","pwd")
              .set("timeout",1000)
              .sync

#SSH Connector Response Parameters
result=response.get("result")                    #Result

 

SSH key data based authentication

SSH Key data based authentication mechanism

Request parameters
ParameterDescriptionRequired
connector_nameName of the SSH Connector to be configuredtrue
targetHost name or ip-address of the remote machine you wish to connect totrue
usernameUsername which will be used to log into remote machine, required for authenticationtrue
pem-dataContent of private key file in String format with each line of content end with '\n' charactertrue
commandCommand to be executed on the host server machinetrue
typeShell execution is of two types - shell and exec.
  • exec each command will be executed in a separate session as if the command is executed in new command shell
  • shell each command will be executed in the same session as if the command is executed in the same command shell
Default execution type is exec.
false
timeoutTimeout in milliseconds, taken by the connector to serve the ssh request. Default timeout is 60,000 msfalse
Response parameters
ParameterDescriptionRequired
resultResults as per the command executedtrue
Example
response=@call.connector("my-ssh-connector")
              .set("target","192.168.2.64")
              .set("username","daniel")
              .set("pem-data","-----BEGIN RSA PRIVATE KEY-----********-----END RSA PRIVATE KEY-----")
              .set("command","pwd")
              .set("timeout",1000)
              .sync

#SSH Connector Response Parameters
result=response.get("result")                    #Result


Connector request error handling

 This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

On this page: