tardis.utilities.executors.sshexecutor module

class tardis.utilities.executors.sshexecutor.ConnectionState(connection: SSHClientConnection, bound: Semaphore)[source]

Bases: NamedTuple

State associated with an active SSH connection

bound: Semaphore

bound on concurrent sessions over the connection

connection: SSHClientConnection

the SSH connection itself

class tardis.utilities.executors.sshexecutor.DupingSSHExecutor(*, wrapper='/bin/bash', **parameters)[source]

Bases: SSHExecutor

async run_command(command, stdin_input=None)[source]

Run command in a shell and provide the result

class tardis.utilities.executors.sshexecutor.MFASSHClient(*args, mfa_config, **kwargs)[source]

Bases: SSHClient

async kbdint_auth_requested() Union[str, None, Awaitable[Optional[str]]][source]

Keyboard-interactive authentication has been requested

This method should return a string containing a comma-separated list of submethods that the server should use for keyboard-interactive authentication. An empty string can be returned to let the server pick the type of keyboard-interactive authentication to perform.

async kbdint_challenge_received(name: str, instructions: str, lang: str, prompts: Sequence[Tuple[str, bool]]) Union[Sequence[str], None, Awaitable[Optional[Sequence[str]]]][source]

A keyboard-interactive auth challenge has been received

This method is called when the server sends a keyboard-interactive authentication challenge.

The return value should be a list of strings of the same length as the number of prompts provided if the challenge can be answered, or None to indicate that some other form of authentication should be attempted.

class tardis.utilities.executors.sshexecutor.SSHExecutor(*, on_disconnect_retry: int | bool = 3, **parameters)[source]

Bases: Executor

Execute shell commands via an SSH connection

This class provides several convenience features over a raw SSH connection:

  • Establishing a connection includes retries for temporary unavailability

  • An established connection is multiplexed for concurrent commands

  • Executing commands are used as feedback on the connection state

  • On connection failure both connection and commands are automatically retried

Notably, these features work in accord: Once a single command fails due to a broken connection, multiplexing means all commands are queued until the connection is reestablished. Retrying failed commands efficiently waits for the single connection to be retried.

Parameters

on_disconnect_retry – Whether to retry commands if the connection is lost

property bounded_connection

Get the current connection with a single reserved session slot

This is a context manager that guards the current SSHClientConnection so that only MaxSessions commands run at once.

property lock

Lock protecting the connection

async run_command(command: str, stdin_input: str | None = None)[source]

Run command in a shell and provide the result

async tardis.utilities.executors.sshexecutor.probe_max_session(connection: SSHClientConnection)[source]

Probe the sshd MaxSessions, i.e. the multiplexing limit per connection