twisted.conch.endpoints.SSHCommandClientEndpoint(object)
class documentationtwisted.conch.endpoints
(View In Hierarchy)
Implements interfaces: twisted.internet.interfaces.IStreamClientEndpoint
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.
Method | __init__ | No summary |
Class Method | newConnection | No summary |
Class Method | existingConnection | 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. |
Parameters | creator | An _ISSHConnectionCreator
provider which will be used to set up the SSH connection which will be used
to run a command. (type: _ISSHConnectionCreator
provider) |
command | The 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. (type: bytes ) |
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 | The reactor to use to establish the connection. (type: IReactorTCP
provider) |
command | See __init__ 's
command argument. | |
username | The username with which to authenticate to the SSH server. (type: bytes ) | |
hostname | The hostname of the SSH server. (type: bytes ) | |
port | The port number of the SSH server. By default, the standard SSH port
number is used. (type: int ) | |
keys | Private keys with which to authenticate to the SSH server, if key
authentication is to be attempted (otherwise None ). (type: list
of Key ) | |
password | The password with which to authenticate to the SSH server, if password
authentication is to be attempted (otherwise None ). (type: bytes
or None ) | |
agentEndpoint | An IStreamClientEndpoint
provider which may be used to connect to an SSH agent, if one is to be used
to help with authentication. (type: IStreamClientEndpoint
provider) | |
knownHosts | The currently known host keys, used to check the host key presented by the
server we actually connect to. (type: KnownHostsFile ) | |
ui | An 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. (type: None
or ConsoleUI ) | |
Returns | A new instance of cls (probably SSHCommandClientEndpoint ). |
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 | An existing connection to an SSH server. (type: SSHConnection ) |
command | See SSHCommandClientEndpoint.newConnection 's
command parameter. (type: bytes ) | |
Returns | A new instance of cls (probably SSHCommandClientEndpoint ). |
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 | protocolFactory | A 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. |
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 | connection | See SSHCommandClientEndpoint.existingConnection 's
connection parameter. |
protocolFactory | See SSHCommandClientEndpoint.connect 's
protocolFactory parameter. | |
Returns | See SSHCommandClientEndpoint.connect 's
return value. |