Skip to content

SSH SSH: Inputs & Outputs

Summary

Each plugin uses a set of dictionaries to store data.

These are used by plugin actions as both inputs and outputs.

This page will cover:

  • The dictionaries used in this plugin
  • The information each dictionary contains

Info

See SSH Client for each action's inputs & outputs.

Dictionary Types

Command

Example

1
2
3
4
5
- ssh.client.run_command:
    command: ls --color=never -lsah
  load:
    ssh_server: ssh_server
  save: directory_listing
Required Keys

command: The command to run

Optional Keys

success: A regular expression matching the prompt when the command succeeds (defaults to the base_prompt)

questions: A list of CommandQuestion dictionaries (defaults to null)

CommandQuestion

  • Contains prompts and responses for questions asked by a command

  • You can supply as many of these questions & answers as you need to

  • Each question prompt must be unique per-command

  • Question prompts that aren't found are ignored

Question Handling

The following process is started if question prompt is found.

  1. The answer to the prompted question is sent
  2. If the response is in base_prompt or success, processing is complete
  3. Or if it's in another question prompt, go back to step 1

If a response isn't found in step 2 or 3 it will be treated as a failure.

Example

1
2
3
4
5
6
7
8
9
- ssh.client.run_commands:
    commands:
      - command: sudo ls --color=never -lsah
        questions:
          prompt: "\[sudo\] password for .*:"
          answer: "{{ ssh_server.password }}"
  load:
    ssh_server: ssh_server
  save: directory_listing
Required Keys

prompt: A regular expression matching the question prompt

answer: The command to run if the question is asked

SCPServer

  • Contains connection details for an SCP server

  • The example below shows the dictionary structure in YAML

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

1
2
3
4
5
scp_server:
  address: 1.2.3.4
  port: 22
  username: [username]
  password: [password]
Required Keys

address: The target IP or DNS address.

port: The target SCP port.

username: Username for authentication.

password: Password for authentication.

SSHKeyAuth

  • Contains SSH connection details for key authentication

  • It is used as an input to many of the actions in this plugin

  • The example below shows the dictionary structure in YAML

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

1
2
3
4
5
6
7
ssh_server:
  address: 1.2.3.4
  port: 22
  username: [username]
  private_key: [private_key_string]
  passphrase: [optional_passphrase]
  base_prompt: "cisco\-\d{3}#"
Required Keys

address: The target IP or DNS address.

port: The target SSH port.

username: Username for authentication.

private_key: RSA private key for authentication.

passphrase: The passphrase for the supplied private_key or null if not required.

base_prompt: A regular expression representing the SSH command prompt.

SSHPasswordAuth

  • Contains SSH connection details for password authentication

  • It is used as an input to many of the actions in this plugin

  • The example below shows the dictionary structure in YAML

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

1
2
3
4
5
6
ssh_server:
  address: 1.2.3.4
  port: 22
  username: [username]
  password: [password]
  base_prompt: "cisco\-\d{3}#"
Required Keys

address: The target IP or DNS address.

port: The target SSH port.

username: Username for authentication.

password: Password for authentication.

base_prompt: A regular expression representing the SSH command prompt.