class documentation

SSHCommandClientEndpoint exposes the command-executing functionality of SSH servers.

SSHCommandClientEndpoint can set up a new SSH connection, authenticate it in any one of a number of different ways (keys, passwords, agents), launch a command over that connection and then associate its input and output with a protocol.

It can also re-use an existing, already-authenticated SSH connection (perhaps one which already has some SSH channels being used for other purposes). In this case it creates a new SSH channel to use to execute the command. Notably this means it supports multiplexing several different command invocations over a single SSH connection.

Class Method existingConnection Create and return a new endpoint which will try to open a new channel on an existing SSH connection and run a command over it. It will not close the connection if there is a problem executing the command or after the command finishes.
Class Method newConnection Create and return a new endpoint which will try to create a new connection to an SSH server and run a command over it. It will also close the connection if there are problems leading up to the command being executed, after the command finishes, or if the connection ...
Method __init__ No summary
Method connect Set up an SSH connection, use a channel from that connection to launch a command, and hook the stdin and stdout of that command up as a transport for a protocol created by the given factory.
Method _executeCommand Given a secured SSH connection, try to execute a command in a new channel created on it and associate the result with a protocol from the given factory.
Instance Variable _command Undocumented
Instance Variable _creator Undocumented
@classmethod
def existingConnection(cls, connection, command): (source)

Create and return a new endpoint which will try to open a new channel on an existing SSH connection and run a command over it. It will not close the connection if there is a problem executing the command or after the command finishes.

Parameters
connection:SSHConnectionAn existing connection to an SSH server.
command:bytesSee SSHCommandClientEndpoint.newConnection's command parameter.
Returns
A new instance of cls (probably SSHCommandClientEndpoint).
@classmethod
def newConnection(cls, reactor, command, username, hostname, port=None, keys=None, password=None, agentEndpoint=None, knownHosts=None, ui=None): (source)

Create and return a new endpoint which will try to create a new connection to an SSH server and run a command over it. It will also close the connection if there are problems leading up to the command being executed, after the command finishes, or if the connection Deferred is cancelled.

Parameters
reactor:IReactorTCP providerThe reactor to use to establish the connection.
commandSee __init__'s command argument.
username:bytesThe username with which to authenticate to the SSH server.
hostname:bytesThe hostname of the SSH server.
port:intThe port number of the SSH server. By default, the standard SSH port number is used.
keys:list of KeyPrivate keys with which to authenticate to the SSH server, if key authentication is to be attempted (otherwise None).
password:bytes or NoneThe password with which to authenticate to the SSH server, if password authentication is to be attempted (otherwise None).
agentEndpoint:IStreamClientEndpoint providerAn IStreamClientEndpoint provider which may be used to connect to an SSH agent, if one is to be used to help with authentication.
knownHosts:KnownHostsFileThe currently known host keys, used to check the host key presented by the server we actually connect to.
ui:None or ConsoleUIAn object for interacting with users to make decisions about whether to accept the server host keys. If None, a ConsoleUI connected to /dev/tty will be used; if /dev/tty is unavailable, an object which answers b"no" to all prompts will be used.
Returns
A new instance of cls (probably SSHCommandClientEndpoint).
def __init__(self, creator, command): (source)
Parameters
creator:_ISSHConnectionCreator providerAn _ISSHConnectionCreator provider which will be used to set up the SSH connection which will be used to run a command.
command:bytesThe command line to execute on the SSH server. This byte string is interpreted by a shell on the SSH server, so it may have a value like "ls /". Take care when trying to run a command like "/Volumes/My Stuff/a-program" - spaces (and other special bytes) may require escaping.
def connect(self, protocolFactory): (source)

Set up an SSH connection, use a channel from that connection to launch a command, and hook the stdin and stdout of that command up as a transport for a protocol created by the given factory.

Parameters
protocolFactoryA Factory to use to create the protocol which will be connected to the stdin and stdout of the command on the SSH server.
Returns
A Deferred which will fire with an error if the connection cannot be set up for any reason or with the protocol instance created by protocolFactory once it has been connected to the command.
def _executeCommand(self, connection, protocolFactory): (source)

Given a secured SSH connection, try to execute a command in a new channel created on it and associate the result with a protocol from the given factory.

Parameters
connectionSee SSHCommandClientEndpoint.existingConnection's connection parameter.
protocolFactorySee SSHCommandClientEndpoint.connect's protocolFactory parameter.
Returns
See SSHCommandClientEndpoint.connect's return value.
_command = (source)

Undocumented

_creator = (source)

Undocumented