Home | Trees | Indices | Help |
---|
|
object --+ | threading._Verbose --+ | threading.Thread --+ | Transport
An SSH Transport attaches to a stream (usually a socket), negotiates an encrypted session, authenticates, and then creates stream tunnels, called Channels, across the session. Multiple channels can be multiplexed across a single session (and often are, in the case of port forwardings).
Instance Methods | |||
|
|||
str |
|
||
Channel |
|
||
|
|||
|
|||
list |
|
||
list |
|
||
list |
|
||
list |
|
||
|
|||
|
|||
|
|||
Exception |
|
||
bool |
|
||
str |
|
||
PKey |
|
||
SecurityOptions |
|
||
PKey |
|
||
string |
|
||
tuple(str, int) |
|
||
Message |
|
||
bool |
|
||
bool |
|
||
Channel |
|
||
|
|||
Channel |
|
||
SFTPClient |
|
||
Channel |
|
||
|
|||
int |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
Static Methods | |||
bool |
|
Properties | |
Inherited from Inherited from |
Method Details |
Create a new SSH session over an existing socket, or socket-like object. This only creates the Transport object; it doesn't begin the SSH session yet. Use connect or start_client to begin a client session, or start_server to begin a server session. If the object is not actually a socket, it must have the following methods:
For ease of use, you may also pass in an address (as a tuple) or a
host string as the
|
Returns a string representation of this object, for debugging.
|
Return the next channel opened by the client over this transport, in
server mode. If no channel is opened before the given timeout,
|
Add a host key to the list of keys used for server mode. When behaving as a server, the host key is used to sign certain packets during the SSH2 negotiation, so that the client can trust that we are who we say we are. Because this is used for signing, the key must contain private key info, not just the public half. Only one key of each type (RSA or DSS) is kept. |
Terminate this Transport without closing the session. On posix systems, if a Transport is open during process forking, both parent and child will share the underlying socket, but only one process can use the connection (without corrupting the session). Use this method to clean up a Transport object without disrupting the other process. Since: 1.5.3 |
Authenticate to the server interactively. A handler is used to answer arbitrary questions from the server. On many servers, this is just a dumb wrapper around PAM. This method will block until the authentication succeeds or fails, peroidically calling the handler asynchronously to get answers to authentication questions. The handler may be called more than once if the server continues to ask questions. The handler is expected to be a callable that will handle calls of the
form: A sample call would thus be: The handler should return a list or tuple of answers to the server's questions. If the server requires multi-step authentication (which is very rare), this method will return a list of auth types permissible for the next step. Otherwise, in the normal case, an empty list is returned.
Since: 1.5 |
Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the BadAuthenticationType exception raised.
Since: 1.5 |
Authenticate to the server using a password. The username and password are sent over an encrypted link. If an Since 1.1, if no event is passed, this method will block until the authentication succeeds or fails. On failure, an exception is raised. Otherwise, the method simply returns. Since 1.5, if no event is passed and If the server requires multi-step authentication (which is very rare), this method will return a list of auth types permissible for the next step. Otherwise, in the normal case, an empty list is returned.
|
Authenticate to the server using a private key. The key is used to sign data from the server, so it must include the private part. If an Since 1.1, if no event is passed, this method will block until the authentication succeeds or fails. On failure, an exception is raised. Otherwise, the method simply returns. If the server requires multi-step authentication (which is very rare), this method will return a list of auth types permissible for the next step. Otherwise, in the normal case, an empty list is returned.
|
Ask the server to cancel a previous port-forwarding request. No more connections to the given address & port will be forwarded across this ssh connection.
|
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for start_client, get_remote_server_key, and Transport.auth_password or Transport.auth_publickey. Use those methods if you want more control. You can use this method immediately after creating a Transport to negotiate encryption with a server. If it fails, an exception will be thrown. On success, the method will return cleanly, and an encrypted session exists. You may immediately call open_channel or open_session to get a Channel object, which is used for data transfer.
Note: If you fail to supply a password or private key, this method may succeed, but a subsequent open_channel or open_session call may fail because you haven't authenticated yet. |
Return any exception that happened during the last server request. This can be used to fetch more specific error information after using calls like start_client. The exception (if any) is cleared after this call.
Since: 1.1 |
Return
Since: 1.4 |
Return the channel name used for this transport's logging.
Since: 1.2 |
Return the host key of the server (in client mode).
Note:
Previously this call returned a tuple of (key type, key string).
You can get the same effect by calling PKey.get_name for the key type, and
|
Return a SecurityOptions object which can be used to tweak the encryption algorithms this transport will permit, and the order of preference for them.
|
Return the active host key, in server mode. After negotiating with
the client, this method will return the negotiated host key. If only one
type of host key was set with add_server_key, that's the only key that will ever be
returned. But in cases where you have set more than one type of host key
(for example, an RSA key and a DSS key), the key type will be negotiated
by the client, and this method will return the key of the type agreed on.
If the host key has not been negotiated yet,
|
Return the username this connection is authenticated for. If the
session is not authenticated (or authentication failed), this method
returns
|
Return the address of the remote side of this Transport, if possible.
This is effectively a wrapper around
|
Make a global request to the remote host. These are normally extensions to the SSH2 protocol.
|
Return true if this session is active (open).
|
Return true if this session is active and authenticated.
|
(optional) Load a file of prime moduli for use in doing group-exchange key negotiation in server mode. It's a rather obscure option and can be safely ignored. In server mode, the remote client may request
"group-exchange" key negotiation, which asks the server to send
a random prime number that fits certain criteria. These primes are
pretty difficult to compute, so they can't be generated on demand. But
many systems contain a file of suitable primes (usually named something
like
Note: This has no effect when used in client mode. |
Request a new channel to the server. Channels are socket-like objects used for the actual transfer of data across the session. You may only request a channel after negotiating encryption (using connect or start_client) and authenticating.
|
Request a new channel back to the client, of type
|
Request a new channel to the server, of type
|
Create an SFTP client channel from an open transport. On success, an SFTP session will be opened with the remote host, and a new SFTPClient object will be returned.
|
Request a new channel to the client, of type
|
Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating new keys causes a pause in traffic both ways as the two sides swap keys and do computations. This method returns when the session has switched to new keys.
|
Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives. The handler parameters are: handler(channel, (origin_addr, origin_port), (server_addr, server_port)) where If no handler is set, the default behavior is to send new incoming forwarded connections into the accept queue, to be picked up via accept.
|
|
Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls.
|
Turn on/off logging a hex dump of protocol traffic at DEBUG level in the logs. Normally you would want this off (which is the default), but if you are debugging something, it may be useful.
|
Turn on/off keepalive packets (default is off). If this is set, after
|
Set the channel for this transport's logging. The default is
Since: 1.1 |
Set the handler class for a subsystem in server mode. If a request for this subsystem is made on an open ssh channel later, this handler will be constructed and called -- see SubsystemHandler for more detailed documentation. Any extra parameters (including keyword arguments) are saved and passed to the SubsystemHandler constructor later.
|
Negotiate a new SSH2 session as a client. This is the first step after creating a new Transport. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When
negotiation is done (successful or not), the given (Since 1.4) If After a successful negotiation, you will usually want to authenticate, calling auth_password or auth_publickey.
Notes:
|
Negotiate a new SSH2 session as a server. This is the first step after creating a new Transport and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When
negotiation is done (successful or not), the given (Since 1.4) If After a successful negotiation, the client will need to authenticate.
Override the methods get_allowed_auths, check_auth_none, check_auth_password, and check_auth_publickey in the given After a successful authentication, the client should request to open a
channel. Override check_channel_request in the given
Note: After calling this method (or start_client or connect), you should no longer directly read from or write to the original socket object. |
Turn on/off compression. This will only have an affect before starting the transport (ie before calling connect, etc). By default, compression is off since it negatively affects interactive sessions.
Since: 1.5.2 |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon May 23 13:50:03 2011 | http://epydoc.sourceforge.net |