Home | Trees | Index | Help |
---|
Package paramiko :: Class Transport |
|
object
--+ |_Verbose
--+ |Thread
--+ | Transport
Channel
s, across the session. Multiple
channels can be multiplexed across a single session (and often are, in
the case of port forwardings).
Method Summary | |
---|---|
Create a new SSH session over an existing socket, or socket-like object. | |
__del__(self)
| |
str |
Returns a string representation of this object, for debugging. |
Channel
|
Return the next channel opened by the client over this transport, in server mode. |
Add a host key to the list of keys used for server mode. | |
list |
Authenticate to the server interactively. |
list |
Try to authenticate to the server using no authentication at all. |
list |
Authenticate to the server using a password. |
list |
Authenticate to the server using a private key. |
Close this session, and any open channels that are tied to it. | |
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. | |
Exception |
Return any exception that happened during the last server request. |
bool |
Return True if the transport is currently logging hex
dumps of protocol traffic. |
str |
Return the channel name used for this transport's logging. |
PKey
|
Return the host key of the server (in client mode). |
SecurityOptions
|
Return a SecurityOptions object which can be used to
tweak the encryption algorithms this transport will permit, and the order
of preference for them. |
PKey
|
Return the active host key, in server mode. |
string |
Return the username this connection is authenticated for. |
Message
|
Make a global request to the remote host. |
bool |
Return true if this session is active (open). |
bool |
Return true if this session is active and authenticated. |
bool |
(optional) Load a file of prime moduli for use in doing group-exchange key negotiation in server mode. (Static method) |
Channel
|
Request a new channel to the server. |
Channel
|
Request a new channel to the server, of type "session" . |
SFTPClient
|
Create an SFTP client channel from an open transport. |
bool |
Force this session to switch to new keys. |
run(self)
| |
Send a junk packet across the encrypted link. | |
Turn on/off logging a hex dump of protocol traffic at DEBUG level in the logs. | |
Turn on/off keepalive packets (default is off). | |
Set the channel for this transport's logging. | |
Set the handler class for a subsystem in server mode. | |
Negotiate a new SSH2 session as a client. | |
Negotiate a new SSH2 session as a server. | |
stop_thread(self)
| |
Turn on/off compression. | |
switch on newly negotiated encryption parameters for inbound traffic | |
switch on newly negotiated encryption parameters for outbound traffic | |
_auth_trigger(self)
| |
_check_banner(self)
| |
id is 'A' - 'F' for the various keys used by ssh | |
used by a kex object to register the next packet type it expects to see | |
_get_cipher(self,
name,
key,
iv)
| |
used by KexGex to find primes for group exchange | |
_get_subsystem_handler(self,
name)
| |
_log(self,
level,
msg)
| |
_negotiate_keys(self,
m)
| |
_parse_channel_open(self,
m)
| |
_parse_channel_open_failure(self,
m)
| |
_parse_channel_open_success(self,
m)
| |
_parse_debug(self,
m)
| |
_parse_disconnect(self,
m)
| |
_parse_global_request(self,
m)
| |
_parse_kex_init(self,
m)
| |
_parse_newkeys(self,
m)
| |
_parse_request_failure(self,
m)
| |
_parse_request_success(self,
m)
| |
announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support. | |
_send_message(self,
data)
| |
send a message, but block if we're in key negotiation. | |
used by a kex object to set the K (root key) and H (exchange hash) | |
used by a Channel to remove itself from the active channel list | |
_verify_key(self,
host_key,
sig)
| |
Inherited from Thread | |
| |
| |
| |
| |
| |
| |
| |
| |
Inherited from _Verbose | |
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
dict |
_channel_handler_table = {96: <unbound method Channel._h...
|
dict |
_cipher_info = {'blowfish-cbc': {'block-size': 8, 'key-s...
|
str |
_CLIENT_ID = 'paramiko_1.5.2'
|
dict |
_compression_info = {'none': (None, None), 'zlib': (<cla...
|
dict |
_handler_table = {80: <function _parse_global_request at...
|
dict |
_kex_info = {'diffie-hellman-group1-sha1': <class 'param...
|
dict |
_key_info = {'ssh-dss': <class 'paramiko.DSSKey'>, 'ssh-...
|
dict |
_mac_info = {'hmac-sha1': {'class': <module 'Crypto.Hash...
|
NoneType |
_modulus_pack = None |
tuple |
_preferred_ciphers = ('aes128-cbc', 'blowfish-cbc', 'aes...
|
tuple |
_preferred_compression = ('none',)
|
tuple |
_preferred_kex = ('diffie-hellman-group1-sha1', 'diffie-...
|
tuple |
_preferred_keys = ('ssh-rsa', 'ssh-dss')
|
tuple |
_preferred_macs = ('hmac-sha1', 'hmac-md5', 'hmac-sha1-9...
|
str |
_PROTO_ID = '2.0'
|
Inherited from Thread | |
bool |
_Thread__initialized = False
|
Instance Method Details |
---|
__init__(self,
sock)
|
__repr__(self)
Returns a string representation of this object, for debugging.
|
accept(self, timeout=None)Return the next channel opened by the client over this transport, in server mode. If no channel is opened before the given timeout,None is returned.
|
add_server_key(self, key)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. |
auth_interactive(self, username, handler, submethods='')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.
|
auth_none(self, username)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 theBadAuthenticationType exception
raised.
|
auth_password(self, username, password, event=None, fallback=True)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
|
auth_publickey(self, username, key, event=None)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.
|
close(self)Close this session, and any open channels that are tied to it. |
connect(self, hostkey=None, username='', password=None, pkey=None)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 open_channel or open_session to get a Channel object, which is used for data
transfer.
|
get_exception(self)Return any exception that happened during the last server request. This can be used to fetch more specific error information after using calls likestart_client . The exception (if any) is
cleared after this call.
|
get_hexdump(self)ReturnTrue if the transport is currently logging hex
dumps of protocol traffic.
|
get_log_channel(self)Return the channel name used for this transport's logging.
|
get_remote_server_key(self)Return the host key of the server (in client mode).
|
get_security_options(self)Return aSecurityOptions object which can be used
to tweak the encryption algorithms this transport will permit, and the
order of preference for them.
|
get_server_key(self)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 withadd_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,
None is returned. In client mode, the behavior is
undefined.
|
get_username(self)Return the username this connection is authenticated for. If the session is not authenticated (or authentication failed), this method returnsNone .
|
global_request(self, kind, data=None, wait=True)Make a global request to the remote host. These are normally extensions to the SSH2 protocol.
|
is_active(self)Return true if this session is active (open).
|
is_authenticated(self)Return true if this session is active and authenticated.
|
open_channel(self, kind, dest_addr=None, src_addr=None)Request a new channel to the server.Channel s 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.
|
open_session(self)Request a new channel to the server, of type"session" . This is just an alias for
open_channel('session') .
|
open_sftp_client(self)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.
|
renegotiate_keys(self)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, or the session has died mid-negotiation.
|
send_ignore(self, bytes=None)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.
|
set_hexdump(self, hexdump)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.
|
set_keepalive(self, interval)Turn on/off keepalive packets (default is off). If this is set, afterinterval seconds without sending any data over the
connection, a "keepalive" packet will be sent (and ignored by
the remote host). This can be useful to keep connections alive over a
NAT, for example.
|
set_log_channel(self, name)Set the channel for this transport's logging. The default is"paramiko.transport" but it can be set to
anything you want. (See the logging module for more info.)
SSH Channels will log to a sub-channel of the one specified.
|
set_subsystem_handler(self, name, handler, *larg, **kwarg)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 constructor later.
|
start_client(self, event=None)Negotiate a new SSH2 session as a client. This is the first step
after creating a new If an event is passed in, this method returns immediately. When
negotiation is done (successful or not), the given (Since 1.4) If auth_password or auth_publickey .
|
start_server(self, event=None, server=None)Negotiate a new SSH2 session as a server. This is the first step
after creating a new 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 check_channel_request in the given
server object to allow channels to be opened.
|
use_compression(self, compress=True)Turn on/off compression. This will only have an affect before starting the transport (ie before callingconnect , etc). By default, compression is
off since it negatively affects interactive sessions and is not fully
tested.
|
_activate_inbound(self)switch on newly negotiated encryption parameters for inbound traffic |
_activate_outbound(self)switch on newly negotiated encryption parameters for outbound traffic |
_compute_key(self, id, nbytes)id is 'A' - 'F' for the various keys used by ssh |
_expect_packet(self, type)used by a kex object to register the next packet type it expects to see |
_get_modulus_pack(self)used by KexGex to find primes for group exchange |
_send_kex_init(self)announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support. |
_send_user_message(self, data)send a message, but block if we're in key negotiation. this is used for user-initiated requests. |
_set_K_H(self, k, h)used by a kex object to set the K (root key) and H (exchange hash) |
_unlink_channel(self, chanid)used by a Channel to remove itself from the active channel list |
Static Method Details |
---|
load_server_moduli(filename=None)(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/etc/ssh/moduli ). If you call
load_server_moduli and it returns True , then
this file of primes has been loaded and we will support
"group-exchange" in server mode. Otherwise server mode will
just claim that it doesn't support that method of key negotiation.
|
Class Variable Details |
---|
_cipher_info
|
_CLIENT_ID
|
_compression_info
|
_handler_table
|
_kex_info
|
_key_info
|
_mac_info
|
_modulus_pack
|
_preferred_ciphers
|
_preferred_compression
|
_preferred_kex
|
_preferred_keys
|
_preferred_macs
|
_PROTO_ID
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Sun Dec 4 11:16:48 2005 | http://epydoc.sf.net |