Skip to content

Latest commit

 

History

History
168 lines (128 loc) · 4.9 KB

plugin-ssh.adoc

File metadata and controls

168 lines (128 loc) · 4.9 KB

SSH Plugin

The plugin provides functionality to execute commands via Secure Shell (SSH) connection protocol.

Properties

It’s allowed to configure unlimited number of SSH connections via mechanism of the dynamic properties. The properties prefix example is:

ssh.server.my-server

where my-server is a key used to refer SSH connection in the steps. The key is defined by users, it must be unique and can’t contain dots.

Steps

Configure dynamic SSH connection

Creates a new dynamic SSH connection from the provided parameters, the connection is available only within the story creating the connection.

When I configure SSH connection with key `$connectionKey` and parameters:$connectionParameters
  • $connectionKey - The key to assign to the creating SSH connection. In case if the key conflicts with a global connection key, the dynamic connection will take precedence within the story.

  • $connectionParameters - The ExamplesTable with SSH connection parameters.

Configure SSH connection dynamically
When I configure SSH connection with key `my-connection` and parameters:
|username |host       |port|password|
|admin    |10.10.10.10|22  |Pa$$w0rd|

Execute commands

Retrieves SSH connection parameters by key, opens SSH session and executes commands remotely via the specified protocol.

When I execute commands `$commands` on $connectionKey over $protocol
  • $commands - Semicolon-separated commands to execute.

  • $connectionKey - The SSH connection key matching any of configured ones.

  • $protocol - The protocol of execution: SSH or SFTP.

    Table 1. The list of the supported SFTP commands
    Command Description

    cd path

    Change remote directory to path

    get remote-path

    Download file

    ls [path]

    Display remote directory listing (optionally directory path can be specified)

    mkdir path

    Create remote directory

    pwd

    Display remote working directory

    rmdir path

    Remove remote directory

    rm path

    Remove remote file

Execute commands via SSH protocol
When I execute commands `cd /; pwd` on my-host over SSH
Execute commands via SFTP protocol
When I execute commands `cd /Users` on my-host over SFTP

Execute commands via SFTP and save the result

Retrieves SSH connection parameters by key, opens SSH session, executes SFTP commands remotely and saves the result of the commands to the variable.

When I execute commands `$commands` on $connectionKey over SFTP and save result to $scopes variable `$variableName`
  • $commands - Semicolon-separated SFTP commands to execute.

    Note

    It’s allowed to combine any SFTP commands, but at least one of them should return result. SFTP commands returning results are:

    • get remote-path

    • ls [path]

    • pwd

  • $connectionKey - The SSH connection key matching any of configured ones.

  • $scopes - The comma-separated set of the variables scopes.

  • $variableName - The name of the variable to save the SFTP commands execution result.

Retrive file via SFTP protocol
When I execute commands `get remote-file.txt` on my-host over SFTP and save result to scenario variable `file-content`

Create a file via SFTP

Retrieves SSH connection parameters by key, opens SSH session and creates file with the given content at the provided remote destination.

When I create file with content `$content` at path `$destination` on $connectionKey over SFTP
  • $content - The content of the file to create.

  • $destination - The remote file destination.

  • $connectionKey - The SSH connection key matching any of configured ones.

Create a file via SFTP
When I create file with content `hello world!` at path `remote-file.txt` on my-host over SFTP

Copy a file via SFTP

Retrieves SSH connection parameters by key, opens SSH session and copies the local file to the remote destination.

When I copy local file located at `$filePath` to path `$destination` on $connectionKey over SFTP
  • $filePath - The path of the file to copy.

  • $destination - The remote file destination.

  • $connectionKey - The SSH connection key matching any of configured ones.

Copy a file via SFTP
When I copy local file located at `local-file.txt` to path `remote-file.txt` on my-host over SFTP