�
Z��[c@s�dZddlmZddlZddlZddlZddlZddlZddlZddl m
Z
mZmZm
Z
ddlmZddlmZmZmZddlZddlmZddlmZdd lmZdd
lmZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGddlHmIZImJZJdd
lKmLZLddlMmNZNmOZOddlPmQZQddlRmSZSddlTmUZUmVZVmWZWmXZXddlYmZZZddl[m\Z\m]Z]ddl^m_Z_ddl`maZambZbmcZcmdZdmeZemfZfddlgmhZhddlimjZjddlkmlZlddlmmnZnddlompZpmqZqmrZrmsZsddltmuZumvZvmwZwgZxd�ZyddlzZzezj{ey�dej|evfd��YZ}de~fd ��YZd!e~fd"��YZ�dS(#s
Core protocol implementation
i����(tprint_functionN(tmd5tsha1tsha256tsha512(tdefault_backend(t
algorithmstCiphertmodes(tutil(tAuthHandler(tGSSAuth(tChannel(+t xfffffffftcMSG_CHANNEL_OPENtcMSG_IGNOREtcMSG_GLOBAL_REQUESTtDEBUGtMSG_KEXINITt
MSG_IGNOREtMSG_DISCONNECTt MSG_DEBUGtERRORtWARNINGtcMSG_UNIMPLEMENTEDtINFOtcMSG_KEXINITtcMSG_NEWKEYStMSG_NEWKEYStcMSG_REQUEST_SUCCESStcMSG_REQUEST_FAILUREtCONNECTION_FAILED_CODEt'OPEN_FAILED_ADMINISTRATIVELY_PROHIBITEDtOPEN_SUCCEEDEDtcMSG_CHANNEL_OPEN_FAILUREtcMSG_CHANNEL_OPEN_SUCCESStMSG_GLOBAL_REQUESTtMSG_REQUEST_SUCCESStMSG_REQUEST_FAILUREtMSG_CHANNEL_OPEN_SUCCESStMSG_CHANNEL_OPEN_FAILUREtMSG_CHANNEL_OPENtMSG_CHANNEL_SUCCESStMSG_CHANNEL_FAILUREtMSG_CHANNEL_DATAtMSG_CHANNEL_EXTENDED_DATAtMSG_CHANNEL_WINDOW_ADJUSTtMSG_CHANNEL_REQUESTtMSG_CHANNEL_EOFtMSG_CHANNEL_CLOSEtMIN_WINDOW_SIZEtMIN_PACKET_SIZEtMAX_WINDOW_SIZEtDEFAULT_WINDOW_SIZEtDEFAULT_MAX_PACKET_SIZEtHIGHEST_USERAUTH_MESSAGE_ID(tZlibCompressortZlibDecompressor(tDSSKey(tKexGextKexGexSHA256(t KexGroup1(t
KexGroup14(t KexGSSGextKexGSSGroup1t
KexGSSGroup14tNullHostKey(tMessage(t
PacketizertNeedRekeyException(tModulusPack(tstring_typestlongtbyte_ordtbtinputtPY2(tRSAKey(tECDSAKey(tServerInterface(t
SFTPClient(tSSHExceptiontBadAuthenticationTypetChannelExceptiontProxyCommandFailure(tretry_on_signaltClosingContextManagertclamp_valuecCsxtD]}|j�qWdS(N(t_active_threadststop_thread(tthr((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_join_lingering_threadsMs
t Transportc
Bs�eZdZe�Ze�ZdZdejZ d�Z
d�Zd�ee
j��Zd�Zd�Zi
iejd6ejd6dd6dd6d6iejd6ejd6dd6dd6d6iejd6ejd6dd6d d6d6iejd6ejd6d!d6dd6d6iejd6ejd6dd6dd6d6iejd6ejd6dd6dd6d6iejd6ejd6dd6d d6d 6iejd6ejd6d!d6dd6d
6iejd6d�d6d!d6dd6d6iejd6d�d6d!d6d d6d6Ziied6d"d#6d6ied6d$d#6d6ied6d d#6d
6ied6d%d#6d6ied6dd#6d6ied6d$d#6d6Z ie!d6e"d6e
d&6Z#ie$d6e%d6e&d6e'd6e(d'6e)d(6e*d)6Z+ie,e-fd*6e,e-fd+6d�d6Z.d�Z/d,Z0e1e2e3e4d-�Z5d.�Z6d/�Z7d0�Z8d1�Z9d�d�d2�Z:d�d�d3�Z;d4�Z<d5�Z=e>d�d6��Z?d7�Z@d8�ZAd9�ZBd�d�d�d:�ZCd�d;�ZDd<�ZEd=�ZFd�d�d�d�d�d>�ZGd�d?�ZHd@�ZIdA�ZJd�dB�ZKdC�ZLdD�ZMd�e4dE�ZNd�dF�ZOd�dGd�d�d�e3e3e4dH�ZPdI�ZQdJ�ZRdK�ZSdL�ZTdM�ZUdN�ZVd�e4dO�ZWd�dP�ZXdGdQ�ZYd�dGdR�ZZdS�Z[dT�Z\dU�Z]dV�Z^dW�Z_dX�Z`e4dY�ZadZ�Zbd[�Zcd\�Zdd]�Zed^�Zfd_�Zgd`�Zhda�Zidb�Zjdc�Zkdd�Zlde�Zmdf�Zndg�Zodh�Zpdi�Zqdj�Zrdk�Zsdl�Ztdm�Zudn�Zvdo�Zwdp�Zxdq�Zydr�Zzds�Z{dt�Z|du�Z}dv�Z~dw�Zdx�Z�dy�Z�dz�Z�d{�Z�d|�Z�d}�Z�d~�Z�d�Z�ie~e�6e�e�6e�e�6e�e�6e�e�6e�e�6e�e�6ewe�6Z�ie�j�e�6e�j�e�6e�j�e�6e�j�e�6e�j�e�6e�j�e�6e�j�e�6e�j�e�6Z�RS(�s�
An SSH Transport attaches to a stream (usually a socket), negotiates an
encrypted session, authenticates, and then creates stream tunnels, called
`channels <.Channel>`, across the session. Multiple channels can be
multiplexed across a single session (and often are, in the case of port
forwardings).
Instances of this class may be used as context managers.
s2.0sparamiko_%ss
aes128-ctrs
aes192-ctrs
aes256-ctrs
aes128-cbcsblowfish-cbcs
aes192-cbcs
aes256-cbcs3des-cbct
arcfour128t
arcfour256s
hmac-sha2-256s
hmac-sha2-512shmac-md5shmac-sha1-96shmac-md5-96s hmac-sha1sssh-rsasssh-dsssdiffie-hellman-group1-sha1sdiffie-hellman-group14-sha1s"diffie-hellman-group-exchange-sha1s$diffie-hellman-group-exchange-sha256tnonetclasstmodeis
block-sizeskey-sizeii iitsizeii@secdsa-sha2-nistp256s(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==s)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==s%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==szlib@openssh.comtzlibg�������?cs�t|_t�t�rl�jdd�}t|�dkrO|ddf�ql|dt|d�f�nt��tkrW�\��d}x�t j
��t jt j�D]�\}} }
}}| t jkr�|}
|}t j |
t j��yt
���fd��Wn"t jk
r5}t|�}q:XPq�q�Wtd�|f��ntjj|�|jt��|_y|jj|j�Wntk
r�nXt��|_d|jd |j|_d
|_d
|_ |_!d|_#|_$d|_%|_&d|_'|_(d|_)d|_*d|_+||_,t|_-d|_.d|_/|j,r�t0d|�|_.d|_1nd|_2d|_3d|_4t|_5t|_6t|_7t�|_8tj9�|_:t;�|_<i|_=i|_>d|_?||_@||_Ad|_Bd|_Cd|_Dd|_EtjF�|_Gtj9�|_Hd|_Id|_JtKjL|jJ�|_M|jjN|jM�d|_Od|_Pd|_Qd|_Rd|_St|_Td|_Ui|_Vg|_WtjX|j:�|_Yi|_ZdS(s-
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:
- ``send(str)``: Writes from 1 to ``len(str)`` bytes, and returns an
int representing the number of bytes written. Returns
0 or raises ``EOFError`` if the stream has been closed.
- ``recv(int)``: Reads from 1 to ``int`` bytes and returns them as a
string. Returns 0 or raises ``EOFError`` if the stream has been
closed.
- ``close()``: Closes the socket.
- ``settimeout(n)``: Sets a (float) timeout on I/O operations.
For ease of use, you may also pass in an address (as a tuple) or a host
string as the ``sock`` argument. (A host string is a hostname with an
optional port (separated by ``":"``) which will be converted into a
tuple of ``(hostname, port)``.) A socket will be connected to this
address and used for communication. Exceptions from the ``socket``
call may be thrown in this case.
.. note::
Modifying the the window and packet sizes might have adverse
effects on your channels created from this transport. The default
values are the same as in the OpenSSH code base and have been
battle tested.
:param socket sock:
a socket or socket-like object to create the session over.
:param int default_window_size:
sets the default window size on the transport. (defaults to
2097152)
:param int default_max_packet_size:
sets the default max packet size on the transport. (defaults to
32768)
.. versionchanged:: 1.15
Added the ``default_window_size`` and ``default_max_packet_size``
arguments.
t:iiisNo suitable address familycs�j��f�S(N(tconnect((thostnametporttsock(s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt<lambda>1ssUnable to connect to %s: %ssSSH-t-tsgssapi-keyexs%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==s)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==s(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==s"diffie-hellman-group-exchange-sha1sdiffie-hellman-group14-sha1sdiffie-hellman-group1-sha1g>@sparamiko.transportiN(s%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==s)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==s(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==s"diffie-hellman-group-exchange-sha1sdiffie-hellman-group14-sha1sdiffie-hellman-group1-sha1([tFalsetactivet
isinstanceRGtsplittlentintttypettupletsockettgetaddrinfot AF_UNSPECtSOCK_STREAMRUterrortstrRQt threadingtThreadt__init__t setDaemontTrueRht
settimeoutt_active_check_timeouttAttributeErrorRDt
packetizert _PROTO_IDt
_CLIENT_IDt
local_versiontremote_versiontlocal_ciphert
remote_ciphertNonetlocal_kex_inittremote_kex_initt local_mact
remote_mactlocal_compressiontremote_compressiont
session_idt
host_key_typethost_keytuse_gss_kextgss_kex_usedtkexgss_ctxttgss_hostRt_preferred_kext
kex_enginetHtKtinitial_kex_donetin_kext
authenticatedt_expected_packettLocktlockt
ChannelMapt _channelstchannel_eventst
channels_seent_channel_countertdefault_max_packet_sizetdefault_window_sizet_forward_agent_handlert_x11_handlert_tcp_handlertsaved_exceptiontEventt
clear_to_sendtclear_to_send_locktclear_to_send_timeouttlog_nameR t
get_loggertloggertset_logtauth_handlertglobal_responsetcompletion_eventtbanner_timeoutthandshake_timeouttserver_modet
server_objecttserver_key_dicttserver_acceptst Conditiontserver_accept_cvtsubsystem_table(tselfRhR�R�tgss_kextgss_deleg_credsthltreasontfamilytsocktypetprotot canonnametsockaddrtaftaddrte((RfRgRhs6/usr/lib/python2.7/site-packages/paramiko/transport.pyR|�s�2 4
cCs�dttt|��t@�}|js6|d7}n�|jdkrq|d|j|j|jddf7}n|j�r�|dt|j �7}n |j
r�|d7}n
|d 7}|d
7}|S(sP
Returns a string representation of this object, for debugging.
s<paramiko.Transport at %ss (unconnected)Rks (cipher %s, %d bits)skey-sizeis (active; %d open channel(s))s (connected; awaiting auth)s
(connecting)t>(thexRHtidR
RmR�t_cipher_infotis_authenticatedRpR�R�(R�tout((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt__repr__�s
cCs|jj�|j�dS(s�
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.
.. versionadded:: 1.5.3
N(Rhtclose(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytatfork�s
cCs
t|�S(s
Return a `.SecurityOptions` object which can be used to tweak the
encryption algorithms this transport will permit (for encryption,
digest/hash operations, public keys, and key exchanges) and the order
of preference for them.
(tSecurityOptions(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytget_security_options�scCstj|�|_dS(s�
Setter for C{gss_host} if GSS-API Key Exchange is performed.
:param str gss_host: The targets name in the kerberos database
Default: The name of the host to connect to
:rtype: Void
N(RttgetfqdnR�(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytset_gss_host�s cCs�t|_|dk r,||_|j�dStj�|_}|j�|dk retj�|nd}x~tr�|jd�|js�|j �}|dk r�|�nt
d��n|j�s�|dk rntj�|krnPqnqnWdS(sj
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 ``Event`` will
be triggered. On failure, `is_active` will return ``False``.
(Since 1.4) If ``event`` is ``None``, this method will not return until
negotiation is done. On success, the method returns normally.
Otherwise an SSHException is raised.
After a successful negotiation, you will usually want to authenticate,
calling `auth_password <Transport.auth_password>` or
`auth_publickey <Transport.auth_publickey>`.
.. note:: `connect` is a simpler method for connecting as a client.
.. note::
After calling this method (or `start_server` or `connect`), you
should no longer directly read from or write to the original socket
object.
:param .threading.Event event:
an event to trigger when negotiation is complete (optional)
:param float timeout:
a timeout, in seconds, for SSH2 session negotiation (optional)
:raises SSHException: if negotiation fails (and no ``event`` was passed
in)
Ng�������?sNegotiation failed.(R~RmR�R�tstartRzR�ttimetwaitt
get_exceptionRQtis_set(R�teventttimeouttmax_timeR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytstart_client�s""
"
*cCs�|dkrt�}nt|_||_t|_|dk rV||_|j�dStj �|_}|j�x`tr�|j
d�|js�|j�}|dk r�|�ntd��n|j
�rvPqvqvWdS(s]
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 ``Event`` will
be triggered. On failure, `is_active` will return ``False``.
(Since 1.4) If ``event`` is ``None``, this method will not return until
negotation is done. On success, the method returns normally.
Otherwise an SSHException is raised.
After a successful negotiation, the client will need to authenticate.
Override the methods `get_allowed_auths
<.ServerInterface.get_allowed_auths>`, `check_auth_none
<.ServerInterface.check_auth_none>`, `check_auth_password
<.ServerInterface.check_auth_password>`, and `check_auth_publickey
<.ServerInterface.check_auth_publickey>` in the given ``server`` object
to control the authentication process.
After a successful authentication, the client should request to open a
channel. Override `check_channel_request
<.ServerInterface.check_channel_request>` in the given ``server``
object to allow channels to be opened.
.. note::
After calling this method (or `start_client` or `connect`), you
should no longer directly read from or write to the original socket
object.
:param .threading.Event event:
an event to trigger when negotiation is complete.
:param .ServerInterface server:
an object used to perform authentication and create `channels
<.Channel>`
:raises SSHException: if negotiation fails (and no ``event`` was passed
in)
Ng�������?sNegotiation failed.(R�ROR~R�R�RmR�R�RzR�R�R�RQR�(R�R�tserverR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytstart_server�s()
cCs||j|j�<dS(s
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.
:param .PKey key:
the host key to add, usually an `.RSAKey` or `.DSSKey`.
N(R�tget_name(R�tkey((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytadd_server_key:scCs*y|j|jSWntk
r%nXdS(s�
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, ``None`` is returned. In client mode, the behavior is undefined.
:return:
host key (`.PKey`) of the type negotiated by the client, or
``None``.
N(R�R�tKeyErrorR�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytget_server_keyHs
cCs�t�t_ddg}|dk r7|jd|�nx:|D]2}ytjj|�tSWq>tk
roq>Xq>Wdt_tS(s�
(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.
:param str filename:
optional path to the moduli file, if you happen to know that it's
not in a standard location.
:return:
True if a moduli file was successfully loaded; False otherwise.
.. note:: This has no effect when used in client mode.
s/etc/ssh/modulis/usr/local/etc/moduliiN( RFR\t
_modulus_packR�tinsertt read_fileR~tIOErrorRl(tfilenamet file_listtfn((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytload_server_moduli]s
cCsR|js
dS|j�x't|jj��D]}|j�q-W|jj�dS(sP
Close this session, and any open channels that are tied to it.
N(RmRYtlistR�tvaluest_unlinkRhR�(R�tchan((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��s
cCs*|js|jr#td��n|jS(s�
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 ``str(key)`` for the key string.
:raises SSHException: if no session is currently active.
:return: public key (`.PKey`) of the remote server
sNo existing session(RmR�RQR�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytget_remote_server_key�s
cCs|jS(s�
Return true if this session is active (open).
:return:
True if the session is still active (open); False if the session is
closed
(Rm(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt is_active�scCs|jdd|d|d|�S(s�
Request a new channel to the server, of type ``"session"``. This is
just an alias for calling `open_channel` with an argument of
``"session"``.
.. note:: Modifying the the window and packet sizes might have adverse
effects on the session created. The default values are the same
as in the OpenSSH code base and have been battle tested.
:param int window_size:
optional window size for this session.
:param int max_packet_size:
optional max packet size for this session.
:return: a new `.Channel`
:raises SSHException: if the request is rejected or the session ends
prematurely
.. versionchanged:: 1.13.4/1.14.3/1.15.3
Added the ``timeout`` argument.
.. versionchanged:: 1.15
Added the ``window_size`` and ``max_packet_size`` arguments.
tsessiontwindow_sizetmax_packet_sizeR�(topen_channel(R�R�R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytopen_session�scCs|jdd|�S(s�
Request a new channel to the client, of type ``"x11"``. This
is just an alias for ``open_channel('x11', src_addr=src_addr)``.
:param tuple src_addr:
the source address (``(str, int)``) of the x11 server (port is the
x11 port, ie. 6010)
:return: a new `.Channel`
:raises SSHException: if the request is rejected or the session ends
prematurely
tx11tsrc_addr(R�(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytopen_x11_channel�s
cCs
|jd�S(s<
Request a new channel to the client, of type
``"auth-agent@openssh.com"``.
This is just an alias for ``open_channel('auth-agent@openssh.com')``.
:return: a new `.Channel`
:raises SSHException:
if the request is rejected or the session ends prematurely
sauth-agent@openssh.com(R�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytopen_forward_agent_channel�scCs|jd||�S(sD
Request a new channel back to the client, of type ``"forwarded-tcpip"``.
This is used after a client has requested port forwarding, for sending
incoming connections back to the client.
:param src_addr: originator's address
:param dest_addr: local (server) connected address
sforwarded-tcpip(R�(R�R�t dest_addr((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytopen_forwarded_tcpip_channel�s c
Cs�|jstd��n|dkr*dn|}|jj�zh|j|�}|j|�}|j�}t�}|j t
�|j|�|j|�|j|�|j|�|dks�|dkr|j|d�|j|d�|j|d�|j|d�n1|dkrD|j|d�|j|d�nt
|�} |jj|| �tj�|j|<}
t|j|<| j|�| j||�Wd|jj�X|j|�tj�}x�trV|
jd �|js|j�}|dkrtd
�}n|�n|
j�r.Pq�||tj�kr�td��q�q�W|jj|�} | dk ry| S|j�}|dkr�td
�}n|�dS(sa
Request a new channel to the server. `Channels <.Channel>` 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.
.. note:: Modifying the the window and packet sizes might have adverse
effects on the channel created. The default values are the same
as in the OpenSSH code base and have been battle tested.
:param str kind:
the kind of channel requested (usually ``"session"``,
``"forwarded-tcpip"``, ``"direct-tcpip"``, or ``"x11"``)
:param tuple dest_addr:
the destination address (address + port tuple) of this port
forwarding, if ``kind`` is ``"forwarded-tcpip"`` or
``"direct-tcpip"`` (ignored for other channel types)
:param src_addr: the source address of this port forwarding, if
``kind`` is ``"forwarded-tcpip"``, ``"direct-tcpip"``, or ``"x11"``
:param int window_size:
optional window size for this session.
:param int max_packet_size:
optional max packet size for this session.
:param float timeout:
optional timeout opening a channel, default 3600s (1h)
:return: a new `.Channel` on success
:raises SSHException: if the request is rejected, the session ends
prematurely or there is a timeout openning a channel
.. versionchanged:: 1.15
Added the ``window_size`` and ``max_packet_size`` arguments.
sSSH session not activeisforwarded-tcpipsdirect-tcpipiiR�Ng�������?sUnable to open channel.sTimeout openning channel.(RmRQR�R�tacquiret_sanitize_window_sizet_sanitize_packet_sizet
_next_channelRCtadd_byteRt
add_stringtadd_intRR�tputRzR�R�R~R�t_set_transportt_set_windowtreleaset_send_user_messageR�R�R�R�tget(
R�tkindRR�R�R�R�tchanidtmR�R�tstart_tsR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��sb)
cs��jstd��nt|�}�jd||fdt�}|dkr]td��n|dkrx|j�}n|dkr��fd�}|}n|�_|S(sm
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 ``server_addr`` and ``server_port`` are the address and port that
the server was listening on.
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`.
:param str address: the address to bind when forwarding
:param int port:
the port to forward, or 0 to ask the server to allocate any port
:param callable handler:
optional handler for incoming forwarded connections, of the form
``func(Channel, (str, int), (str, int))``.
:return: the port number (`int`) allocated by the server
:raises SSHException: if the server refused the TCP forward request
sSSH session not actives
tcpip-forwardR�sTCP forwarding request deniedics�j|�dS(N(t_queue_incoming_channel(tchannelR�tdest_addr_port(R�(s6/usr/lib/python2.7/site-packages/paramiko/transport.pytdefault_handlerssN(RmRQRqtglobal_requestR~R�tget_intR�(R�taddressRgthandlertresponseR((R�s6/usr/lib/python2.7/site-packages/paramiko/transport.pytrequest_port_forwardNs cCs6|js
dSd|_|jd||fdt�dS(s.
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.
:param str address: the address to stop forwarding
:param int port: the port to stop forwarding
Nscancel-tcpip-forwardR�(RmR�R�RR~(R�RRg((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytcancel_port_forward{s cCs
tj|�S(sE
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.
:return:
a new `.SFTPClient` referring to an sftp session (channel) across
this transport
(RPtfrom_transport(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytopen_sftp_client�s
cCsit�}|jt�|dkrBttjd��dd}n|jtj|��|j|�dS(s�
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.
:param int byte_count:
the number of random bytes to send in the payload of the ignored
packet -- defaults to a random number from 10 to 41.
ii i
N( RCRRR�RItosturandomt add_bytesR(R�t
byte_countR((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytsend_ignore�s
cCs�tj�|_|j�xftr�|jjd�|jsk|j�}|dk r\|�nt d��n|jj
�rPqqWdS(s9
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.
:raises SSHException: if the key renegotiation failed (which causes the
session to end)
g�������?sNegotiation failed.N(RzR�R�t_send_kex_initR~R�RmR�R�RQR�(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytrenegotiate_keys�s
cCs&|jj|tj|�d��dS(s�
Turn on/off keepalive packets (default is off). If this is set, after
``interval`` 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.
:param int interval:
seconds to wait before sending a keepalive packet (or
0 to disable keepalives).
cSs|jddt�S(Nskeepalive@lag.netR�(RRl(tx((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRi�sN(R�t
set_keepalivetweakreftproxy(R�tinterval((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR)�scCs�|rtj�|_nt�}|jt�|j|�|j|�|dk rd|j |�n|j
td|�|j|�|s�dSx:t
r�|jjd�|js�dS|jj�r�Pq�q�W|jS(s�
Make a global request to the remote host. These are normally
extensions to the SSH2 protocol.
:param str kind: name of the request.
:param tuple data:
an optional tuple containing additional data to attach to the
request.
:param bool wait:
``True`` if this method should not return until a response is
received; ``False`` otherwise.
:return:
a `.Message` containing possible additional data if the request was
successful (or an empty `.Message` if ``wait`` was ``False``);
``None`` if the request was denied.
sSending global request "%s"g�������?N(RzR�R�RCRRRtadd_booleanR�taddt_logRRR~R�RmR�R�(R�RtdataR�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�s&
cCs�|jj�znt|j�dkr:|jjd�}n@|jj|�t|j�dkrt|jjd�}nd}Wd|jj�X|S(sW
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.
:param int timeout:
seconds to wait for a channel, or ``None`` to wait forever
:return: a new `.Channel` opened by the client
iN( R�RRpR�tpopR�R�R�R
(R�R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytaccept�s
Rkc
Cs�|d k r!|j�g|_n|j�|d k r|r|j�} | j�|j�ksz| j�|j�kr�|jtd�|jtd|j�t|j��f�|jtd| j�t| j��f�t d��n|jtd|j��n|d k s2|d k s2|s2|r�|r^|jtd�|j
|||�q�|r�|jtd�|j|�q�|d k r�|jtd�|j||�q�|jtd�|j
||�nd S(
s�
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.
:param .PKey hostkey:
the host key expected from the server, or ``None`` if you don't
want to do host key verification.
:param str username: the username to authenticate as.
:param str password:
a password to use for authentication, if you want to use password
authentication; otherwise ``None``.
:param .PKey pkey:
a private key to use for authentication, if you want to use private
key authentication; otherwise ``None``.
:param str gss_host:
The target's name in the kerberos database. Default: hostname
:param bool gss_auth:
``True`` if you want to use GSS-API authentication.
:param bool gss_kex:
Perform GSS-API Key Exchange and user authentication.
:param bool gss_deleg_creds:
Whether to delegate GSS-API client credentials.
:raises SSHException: if the SSH2 negotiation fails, the host key
supplied by the server is incorrect, or authentication fails.
sBad host key from serversExpected: %s: %ssGot : %s: %ssHost key verified (%s)s,Attempting GSS-API auth... (gssapi-with-mic)s)Attempting GSS-API auth... (gssapi-keyex)sAttempting public-key auth...sAttempting password auth...N(R�R�t_preferred_keysR�R�tasbytesR/RtreprRQtauth_gssapi_with_mictauth_gssapi_keyextauth_publickeyt
auth_password(
R�thostkeytusernametpasswordtpkeyR�tgss_authR�R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRes0+
0,,$cCs<|jj�z|j}d|_|SWd|jj�XdS(sy
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.
:return:
an exception, or ``None`` if there is no stored exception.
.. versionadded:: 1.1
N(R�RR�R�R
(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�Xs
cOs<z'|jj�|||f|j|<Wd|jj�XdS(s-
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.
:param str name: name of the subsystem.
:param class handler:
subclass of `.SubsystemHandler` that handles this subsystem.
N(R�RR�R
(R�tnameRtlargtkwarg((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytset_subsystem_handlerls
cCs%|jo$|jdk o$|jj�S(s
Return true if this session is active and authenticated.
:return:
True if the session is still open and has been authenticated
successfully; False if authentication failed and/or the session is
closed.
N(RmR�R�R�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��s cCs*|js|jdkrdS|jj�S(s
Return the username this connection is authenticated for. If the
session is not authenticated (or authentication failed), this method
returns ``None``.
:return: username that was authenticated (a `str`), or ``None``.
N(RmR�R�tget_username(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRC�scCs'|js|jdkrdS|jjS(s�
Return the banner supplied by the server upon connect. If no banner is
supplied, this method returns ``None``.
:returns: server supplied banner (`str`), or ``None``.
.. versionadded:: 1.13
N(RmR�R�tbanner(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt
get_banner�s cCsa|js|jr#td��ntj�}t|�|_|jj||�|jj|�S(s�
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.
:param str username: the username to authenticate as
:return:
`list` of auth types permissible for the next stage of
authentication (normally empty)
:raises BadAuthenticationType: if "none" authentication isn't allowed
by the server for this user
:raises SSHException: if the authentication failed due to a network
error
.. versionadded:: 1.5
sNo existing session( RmR�RQRzR�R
R�t auth_nonetwait_for_response(R�R;tmy_event((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRF�scs|js|jr#td��n|dkr>tj�}n|}t|�|_|jj|�|�|dk rygSy|jj |�SWnlt
k
r�}|s�d|jkr��ny#�fd�}|j||�SWq�tk
r�|�q�XnXdS(sh
Authenticate to the server using a password. The username and password
are sent over an encrypted link.
If an ``event`` is passed in, this method will return immediately, and
the event will be triggered once authentication succeeds or fails. On
success, `is_authenticated` will return ``True``. On failure, you may
use `get_exception` to get more detailed error information.
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 ``fallback`` is ``True`` (the
default), if the server doesn't support plain password authentication
but does support so-called "keyboard-interactive" mode, an attempt
will be made to authenticate using this interactive mode. If it fails,
the normal exception will be thrown as if the attempt had never been
made. This is useful for some recent Gentoo and Debian distributions,
which turn off plain password authentication in a misguided belief
that interactive authentication is "more secure". (It's not.)
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.
:param str username: the username to authenticate as
:param basestring password: the password to authenticate with
:param .threading.Event event:
an event to trigger when the authentication attempt is complete
(whether it was successful or not)
:param bool fallback:
``True`` if an attempt at an automated "interactive" password auth
should be made if the server doesn't support normal password auth
:return:
`list` of auth types permissible for the next stage of
authentication (normally empty)
:raises BadAuthenticationType: if password authentication isn't
allowed by the server for this user (and no event was passed in)
:raises AuthenticationException: if the authentication failed (and no
event was passed in)
:raises SSHException: if there was a network error
sNo existing sessionskeyboard-interactivecs>t|�dkr!td��nt|�dkr7gS�gS(NisFallback authentication failed.i(RpRQ(ttitletinstructionstfields(R<(s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�s
N(
RmR�RQR�RzR�R
R�R9RGRRt
allowed_typestauth_interactive(R�R;R<R�tfallbackRHR�R((R<s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR9�s&-
cCs�|js|jr#td��n|dkr>tj�}n|}t|�|_|jj|||�|dk rygS|jj |�S(s`
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 ``event`` is passed in, this method will return immediately, and
the event will be triggered once authentication succeeds or fails. On
success, `is_authenticated` will return ``True``. On failure, you may
use `get_exception` to get more detailed error information.
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.
:param str username: the username to authenticate as
:param .PKey key: the private key to authenticate with
:param .threading.Event event:
an event to trigger when the authentication attempt is complete
(whether it was successful or not)
:return:
`list` of auth types permissible for the next stage of
authentication (normally empty)
:raises BadAuthenticationType: if public-key authentication isn't
allowed by the server for this user (and no event was passed in)
:raises AuthenticationException: if the authentication failed (and no
event was passed in)
:raises SSHException: if there was a network error
sNo existing sessionN(
RmR�RQR�RzR�R
R�R8RG(R�R;R�R�RH((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR8
s!cCsg|js|jr#td��ntj�}t|�|_|jj||||�|jj|�S(s�
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: ``handler(title, instructions, prompt_list)``. The ``title`` is
meant to be a dialog-window title, and the ``instructions`` are user
instructions (both are strings). ``prompt_list`` will be a list of
prompts, each prompt being a tuple of ``(str, bool)``. The string is
the prompt and the boolean indicates whether the user text should be
echoed.
A sample call would thus be:
``handler('title', 'instructions', [('Password:', False)])``.
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.
:param str username: the username to authenticate as
:param callable handler: a handler for responding to server questions
:param str submethods: a string list of desired submethods (optional)
:return:
`list` of auth types permissible for the next stage of
authentication (normally empty).
:raises BadAuthenticationType: if public-key authentication isn't
allowed by the server for this user
:raises AuthenticationException: if the authentication failed
:raises SSHException: if there was a network error
.. versionadded:: 1.5
sNo existing session( RmR�RQRzR�R
R�RMRG(R�R;Rt
submethodsRH((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRM<s+cCs%|sd�}n|j|||�S(s
Autenticate to the server interactively but dumber.
Just print the prompt and / or instructions to stdout and send back
the response. This is good for situations where partial auth is
achieved by key and then the user has to enter a 2fac token.
cSsyg}|rt|j��n|r8t|j��nx:|D]2\}}t|j�dd�|jt��q?W|S(Ntendt (tprinttstriptappendRK(RIRJtprompt_listtanswerstpromptt
show_input((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRxs(RM(R�R;RRO((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytauth_interactive_dumbos
cCsg|js|jr#td��ntj�}t|�|_|jj||||�|jj|�S(s�
Authenticate to the Server using GSS-API / SSPI.
:param str username: The username to authenticate as
:param str gss_host: The target host
:param bool gss_deleg_creds: Delegate credentials or not
:return: list of auth types permissible for the next stage of
authentication (normally empty)
:rtype: list
:raise BadAuthenticationType: if gssapi-with-mic isn't
allowed by the server (and no event was passed in)
:raise AuthenticationException: if the authentication failed (and no
event was passed in)
:raise SSHException: if there was a network error
sNo existing session( RmR�RQRzR�R
R�R6RG(R�R;R�R�RH((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR6�scCsa|js|jr#td��ntj�}t|�|_|jj||�|jj|�S(sJ
Authenticate to the server with GSS-API/SSPI if GSS-API kex is in use.
:param str username: The username to authenticate as.
:returns:
a `list` of auth types permissible for the next stage of
authentication (normally empty)
:raises BadAuthenticationType:
if GSS-API Key Exchange was not performed (and no event was passed
in)
:raises AuthenticationException:
if the authentication failed (and no event was passed in)
:raises SSHException: if there was a network error
sNo existing session( RmR�RQRzR�R
R�R7RG(R�R;RH((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR7�scCs2||_tj|�|_|jj|j�dS(sg
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.
:param str name: new channel name for logging
.. versionadded:: 1.1
N(R�R R�R�R�R�(R�R?((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytset_log_channel�s cCs|jS(s�
Return the channel name used for this transport's logging.
:return: channel name as a `str`
.. versionadded:: 1.2
(R�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytget_log_channel�scCs|jj|�dS(sa
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.
:param bool hexdump:
``True`` to log protocol traffix (in hex) to the log; ``False``
otherwise.
N(R�tset_hexdump(R�thexdump((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR\�s
cCs
|jj�S(s�
Return ``True`` if the transport is currently logging hex dumps of
protocol traffic.
:return: ``True`` if hex dumps are being logged, else ``False``.
.. versionadded:: 1.4
(R�tget_hexdump(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR^�s cCs|rd|_n d|_dS(s�
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.
:param bool compress:
``True`` to ask the remote client/server to compress traffic;
``False`` to refuse compression
.. versionadded:: 1.5.2
szlib@openssh.comRcR_N(szlib@openssh.comszlibR_(R_(t_preferred_compression(R�tcompress((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytuse_compression�scCs,t|jdd�}|dkr%dS|�S(s�
Return the address of the remote side of this Transport, if possible.
This is effectively a wrapper around ``'getpeername'`` on the underlying
socket. If the socket-like object has no ``'getpeername'`` method,
then ``("unknown", 0)`` is returned.
:return:
the address of the remote host, if known, as a ``(str, int)``
tuple.
tgetpeernametunknowniN(sunknowni(tgetattrRhR�(R�tgp((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRb�scCs�t|_|jj�trQx~|j�rM|tj�k rM|jd�qWnLxI|j�r�|tj�k r�|j j
r�|jjr�|jd�qTWdS(Ni
g�������?(RlRmR�R�RLtis_aliveRztcurrent_threadtjoinRht_closedtclosed(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRYs
!cGsVtt|�t�r<x:|D]}|jj||�qWn|jj|||�dS(N(t
issubclassRrR�R�tlog(R�tleveltmsgtargsR((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR/s
cCs|jS(s0used by KexGex to find primes for group exchange(R�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_get_modulus_pack"scCs]|j}x9|jj|�dk rD|jdd@|_|j}qW|jdd@|_|S(syou are holding the lockii���N(R�R�RR�(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR&s
cCs|jj|�dS(s?used by a Channel to remove itself from the active channel listN(R�tdelete(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_unlink_channel/scCs|jj|�dS(N(R�tsend_message(R�R0((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt
_send_message3scCs�tj�}x�tr�|jjd�|jsB|jtd�dS|jj�|jj �rbPn|jj
�tj�||jkrtd��qqWz|j
|�Wd|jj
�XdS(s{
send a message, but block if we're in key negotiation. this is used
for user-initiated requests.
g�������?s0Dropping user packet because connection is dead.Ns2Key-exchange timed out waiting for key negotiation(R�R~R�R�RmR/RR�RR�R
R�RQRt(R�R0R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR6s
cCs1||_||_|jdkr-||_ndS(sBused by a kex object to set the K (root key) and H (exchange hash)N(R�R�R�R�(R�tkth((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_set_K_HLs cGst|�|_dS(sGused by a kex object to register the next packet type it expects to seeN(RsR�(R�tptypes((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_expect_packetSscCsu|j|jt|��}|dkr7td��n|j|jt|��shtd|j��n||_dS(NsUnknown host key types#Signature verification (%s) failed.(t _key_infoR�RCR�RQtverify_ssh_sigR�R�(R�R�tsigR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_verify_keyWsc Csjt�}|j|j�|j|j�|jt|��|j|j�t|j dd�}d|j jj|f}|dkr�t
}|d7}nt|d�s�|jt|�t|dt�n||j��j�}}xxt|�|krat�}|j|j�|j|j�|j|�||j��j�}||7}||7}q�W|| S(s0id is 'A' - 'F' for the various keys used by ssht hash_algos$kex engine %s specified hash_algo %rs, falling back to sha1t_logged_hash_selectionN(RCt add_mpintR�R#R�RRJR�RdR�R�t __class__t__name__RthasattrR/RtsetattrR~R4tdigestRp( R�R�tnbytesRR~thash_select_msgR�tsofarR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_compute_key_s.
cCs�||jkr"td|��n|d kr�t|j|d|�ddt��}||jkru|j�}n|j�}|jdd�|St|j|d|�|j|d|�dt��}||jkr�|j�S|j�SdS(
NsUnknown client cipher R]R^R`tbackendRQiRa(R]R^( R�RQRR�Rt_ENCRYPTt encryptort decryptortencrypt(R�R?R�tivt operationtciphertengine((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_get_cipher{s&
cs4|dkr'�fd�}|�_n |�_dS(Ncs�j|�dS(N(R(R(R�(s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�s(R�R�(R�RR((R�s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_set_forward_agent_handler�scs4|dkr'�fd�}|�_n |�_dS(Ncs�j|�dS(N(R(Rt
src_addr_port(R�(s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�s(R�R�(R�RR((R�s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_set_x11_handler�scCsC|jj�z!|jj|�|jj�Wd|jj�XdS(N(R�RR�RTR�tnotifyR
(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�s
cCs(|dkr|j}ntt|t�S(N(R�R�RWR2R4(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�scCs(|dkr|j}ntt|t�S(N(R�R�RWR3R4(R�R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�scCs�|js"|tks"|j�r&dSt�}|tkrK|jt�nh|tkr�|j �}|j
�}|jt�|j|�|jt
�|jd�|jd�n|S(so
Checks message type against current auth state.
If server mode, and auth has not succeeded, and the message is of a
post-auth type (channel open or global request) an appropriate error
response Message is crafted and returned to caller for sending.
Otherwise (client mode, authed, or pre-auth message) returns None.
RktenN(R�R7R�R�RCR$RRR)tget_textRR"R R R(R�tptypetmessagetreplyRR((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_ensure_authed�s
c
Cs*t|_tj|�|jrL|jtdttt|��t @��n*|jtdttt|��t @��y�y9|j
jt|j
d��|jtd|j
�|j�|j
j|j�|j�|jt�x�|jr�|j
j�r|jr|j�ny|j
j�\}}Wntk
rEq�nX|tkrXq�nR|tkr�|j|�t|_|j
j�Pn|tkr�|j|�q�nt |j!�dkr*||j!kr�t"d|j!|f��nt#�|_!|dkr*|dkr*|j$j%||�q�q*n||j&krx|j'||�}|ra|j(|�q�|j&|||�n(||j)kr|j*�}|j+j,|�}|dk r�|j)|||�q�||j.kr�|jtd |�q�|jt/d
|�t|_|j
j�n�|j0dk rY||j0j&krY|j0j&||j0|�nG|jt1d|�t2�}|j3t4�|j5|j6�|j(|�|j
j7�q�WWnWt"k
r}|jt/dt8|��|jt/t9j:��||_;nt<k
r+}|jtd
�||_;n�t=j>k
r�}t?|j@�t#kr�|j@r|d|j@d|j@df}q�t8|�p�tA|�}n |j@}|jt/d|�||_;nLtBk
r}|jt/dt8|��|jt/t9j:��||_;nXtjC|�x'tD|j+jE��D]}|jF�q/W|jr�t|_|j
j�|jGdk r�|jGjH�n|j0dk r�|j0jI�nx!|jJjE�D]} | jH�q�Wz|jKjL�|jMjN�Wd|jKjO�Xn|jPj�Wn|jjQdk r&�q&nXdS(Ns!starting thread (server mode): %ss!starting thread (client mode): %ss
sLocal version/idstring: %sis Expecting packet from %r, got %dii)s$Ignoring message for dead channel %ds&Channel request for unknown channel %dsOops, unhandled type %dsException: sEOF in transport threads%s (%d)isSocket exception: sUnknown exception: (RtsysRXRTR�R/RR�RHR�R
R�t write_allRJR�t
_check_bannertstart_handshakeR�R&RyRRmt
need_rekeyR�tread_messageRERRt_parse_disconnectRlR�Rt_parse_debugRpR�RQRsR�t
parse_nextt_handler_tableR�Rtt_channel_handler_tableRR�RR�R�RR�RRCRRR tseqnotcomplete_handshakeRyR t
tb_stringsR�tEOFErrorRtRxRrRoR5t ExceptiontremoveR�R�R�R�tsettabortR�R�RR�R�R
Rhtmodules(
R�R�Rt error_msgRR�RnR�temsgR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytrun�s�
-*
!
!
cCsRdj|�}||kr(||7}n|dj||�7}|jt|�dS(Ns{0} agreed: slocal={0}, remote={1}(tformatR/R(R�twhichtlocaltremoteRn((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_log_agreementfs
cCsi|jj�z|jj�Wd|jj�X|jdkrK|j�n|j|�|j j
�dS(N(R�RR�tclearR
R�R�R&t_parse_kex_initR�t start_kex(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_negotiate_keysss
c Cs�x�td�D]�}|dkr+|j}nd}y|jj|�}Wn<tk
r]�n)tk
r�}tdt|���nX|d dkr�Pn|jt d|�q
W|d dkr�td|d ��n||_
|jt d
|�d}|jd�}|dkr2||d
}|| }n|jdd�}t
|�dkretd��n|d
}|d}|dkr�|dkr�td|f��n|jtd||f�dS(Nidiis!Error reading SSH protocol bannerisSSH-sBanner: s!Indecipherable protocol version "t"sRemote version/idstring: %sRkRQiRjisInvalid SSH banners1.99s2.0s(Incompatible version (%s instead of 2.0)s!Connected (version %s, client %s)(trangeR�R�treadlineRTR�RQRyR/RR�tfindRoRpR( R�tiR�tbufR�tcommenttsegstversiontclient((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��s<
cCs|jj�z|jj�Wd|jj�Xt|_|jrd}g|jD]}|j |�rQ|^qQ}|j
dkr�t|�dkr�g|j
�jD]}|j |�s�|^q�}||j
�_nttt|jj��j|j��}n |j}t�}|jt�|jtjd��|j|j�|j|�|j|j�|j|j�|j|j�|j|j�|j|j�|j|j�|jt ��|jt ��|j!t"�|j#d�|j$�|_%|j&|�dS(s�
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
Ns!diffie-hellman-group-exchange-shaii('R�RR�R�R
R~R�R�R�t
startswithR�R�RpR�tkexR�tfilterR�tkeyst__contains__R3RCRRR#R!R"tadd_listt_preferred_cipherst_preferred_macsR_RtbytesR-RlR R4R�Rt(R�tmp_required_prefixRutkex_mptpkextavailable_server_keysR((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR&�s@
+!
c
Csn|jd�}|j�}|j�}|j�}|j�}|j�}|j�}|j�} |j�}
|j�}|j�}|j�}
|j�}|jtdt|�dt|�dt|�dt|�dt|�dt|�dt| �d t|
�d
t|�dt|�dt|
��|jrltt |j
j|��}ntt |j|j
��}t|�d
kr�t
d��n|j|d
|�|_|jtd|d
�|jr(tt t|jj��j|j��}tt |j|��}ntt |j|j��}t|�d
krdt
d��n|d
|_|jr�|j�dkr�t
d��n|jr�tt |jj|��}tt |jj|��}n6tt |j|j��}tt |j|j��}t|�d
ks7t|�d
krFt
d��n|d
|_|d
|_|jdd|jd|j�|jr�tt |jj|��}tt |jj|��}n6tt |j|j��}tt |j|j��}t|�d
kst|�d
kr*t
d��n|d
|_|d
|_|jdd|jd|j�|jr�tt |jj| ��}tt |jj|
��}n6tt | j|j��}tt |
j|j��}t|�d
ks�t|�d
krt
d|||jf��n|d
|_|d
|_|jdd|jd|j�t |j!�|_"dS(Nis
kex algos:s server key:s client encrypt:s server encrypt:s client mac:s server mac:s client compress:s server compress:s
client lang:s
server lang:s
kex follows?is3Incompatible ssh peer (no acceptable kex algorithm)sKex agreed: %ss.Incompatible ssh peer (no acceptable host key)s;Incompatible ssh peer (can't match requested host key type)s/Incompatible ssh server (no acceptable ciphers)RR�R�s,Incompatible ssh server (no acceptable macs)tMACs<Incompatible ssh server (no acceptable compression) %r %r %rtCompression(#t get_bytestget_listtget_booleanRR/RRyR�R�R�R�R�RpRQt _kex_infoR�R�R�R3R�R�R�R�R�R�R�R�R�R�R_R�R�Rt
get_so_farR�(R�Rtcookiet
kex_algo_listtserver_key_algo_listtclient_encrypt_algo_listtserver_encrypt_algo_listtclient_mac_algo_listtserver_mac_algo_listtclient_compress_algo_listtserver_compress_algo_listtclient_lang_listtserver_lang_listtkex_followstunusedt
agreed_kexR�tagreed_keystagreed_local_cipherstagreed_remote_cipherstagreed_remote_macstagreed_local_macstagreed_remote_compressiontagreed_local_compression((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��s� �
$
$
$
c Cs�|j|jd}|jrR|jd|�}|jd|j|jd�}n2|jd|�}|jd|j|jd�}|j|j|||j�}|j|jd}|j|jd}|jr�|jd |�j�}n|jd
|�j�}|j j
|||||�|j|jd}|dk r�|jdksZ|jr�|jtd
�|j j|��ndS(sDswitch on newly negotiated encryption parameters for inbound traffics
block-sizetAtCskey-sizetBtDRbR`tEtFiszlib@openssh.coms$Switching on inbound compression ...N(R�R�R�R�R�t_DECRYPTt _mac_infoR�tdigest_sizeR�tset_inbound_ciphert_compression_infoR�R�R�R/Rtset_inbound_compressor( R�t
block_sizetIV_intkey_inR�tmac_sizet
mac_enginetmac_keytcompress_in((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_activate_inboundBs" # $cCs�t�}|jt�|j|�|j|jd}|jru|jd|�}|jd|j|jd�}n2|jd|�}|jd|j|jd�}|j|j|||j �}|j
|jd}|j
|jd}|jr|jd |�j�}n|jd
|�j�}|jj
d�} |jj|||||| �|j|jd}
|
dk r�|jd
ks�|jr�|jtd�|jj|
��n|jj�s�t|_n|jt�dS(sEswitch on newly negotiated encryption parameters for outbound traffics
block-sizeR�R�skey-sizeR�R�RbR`R�R�s-ctriszlib@openssh.coms%Switching on outbound compression ...N(RCRRRtR�R�R�R�R�R�R�R�R�tendswithR�tset_outbound_cipherR�R�R�R�R/Rtset_outbound_compressorR�RlR�RyR(R�RR�tIV_outtkey_outR�RRRtsdctrtcompress_out((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_activate_outboundZs0
# $cCs�t|_|jdkrR|j|jd}|jtd�|jj|��n|jdkr�|j|jd}|jtd�|jj |��ndS(Nszlib@openssh.comis%Switching on outbound compression ...is$Switching on inbound compression ...(
R~R�R�R�R/RR�RR�R�(R�RR((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt
_auth_triggerzs cCs�|jtd�|j�d|_|_d|_d|_|jrf|j dkrft
|�|_ n|js{t|_n|j
dk r�|j
j�n|jj�s�t|_n|jj�z|jj�Wd|jj�XdS(NsSwitch to new keys ...(R/RRR�R�R�R�R�R�R�R
R�R~R�R�R�R�RlR�R�RR�R
(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_newkeys�s$
cCs6|j�}|j�}|jtd||f�dS(NsDisconnect (code %d): %s(RR�R/R(R�Rtcodetdesc((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR��sc Cso|j�}|jtd|�|j�}|jsR|jtd|�t}n�|dkr�|j�}|j�}|jj||�}|r�|f}q�nU|dkr�|j�}|j�}|jj ||�t
}n|jj||�}d}t|�t
kr|}t
}n|rkt�}|rN|jt�|j|�n
|jt�|j|�ndS(NsReceived global request "%s"s*Rejecting "%s" global request from server.s
tcpip-forwardscancel-tcpip-forward((R�R/RR�R�RlRR�tcheck_port_forward_requesttcancel_port_forward_requestR~tcheck_global_requestRrRsRCRRR.RRt( R�RRt
want_replytokRRgtextraRn((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_global_request�s:
cCs<|jtd�||_|jdk r8|jj�ndS(NsGlobal request successful.(R/RR�R�R�R�(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_request_success�s cCs<|jtd�d|_|jdk r8|jj�ndS(NsGlobal request denied.(R/RR�R�R�R�(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_request_failure�s cCs�|j�}|j�}|j�}|j�}|jj|�}|dkrb|jtd�dS|jj�zX|j|||�|jt d|�||j
kr�|j
|j�|j
|=nWd|jj�XdS(Ns%Success for unrequested channel! [??]sSecsh channel %d opened.(
RR�RR�R/RR�Rt_set_remote_channelRR�R�R
(R�RRt
server_chanidtserver_window_sizetserver_max_packet_sizeR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_channel_open_success�s"
cCs�|j�}|j�}|j�}|j�}tj|d�}|jtd|||f�|jj�zet||�|_ ||j
kr�|jj|�||j
kr�|j
|j
�|j
|=q�nWd|jj�XdS(Ns(unknown code)s$Secsh channel %d open FAILED: %s: %s(RR�RRR/RR�RRSR�R�R�RqR�R
(R�RRR�t
reason_strtlangtreason_text((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_channel_open_failure�s
cCs�|j�}|j�}|j�}|j�}t}|dkr�|jdk r�|jtd�|jj�z|j �}Wd|jj
�Xn|dkr|jdk r|j�}|j�} |jtd|| f�|jj�z|j �}Wd|jj
�Xn�|dkr�|jdk r�|j�}
|j�}|j�}|j�} |jtd|| f�|jj�z|j �}Wd|jj
�Xn�|j
s�|jtd|�t}t}n�|jj�z|j �}Wd|jj
�X|dkrc|j�}
|j�}|j�}|j�} |jj||| f|
|f�}n|jj||�}|tkr�|jtd |�t}n|rt�}|jt�|j|�|j|�|jd
�|jd�|j|�dSt|�}|jj�zZ|jj||�t|j|<|j|�|j|j |j!�|j"|||�Wd|jj
�Xt�}|jt#�|j|�|j|�|j|j �|j|j!�|j|�|jtd||�|dkr|j|�no|dkr:|j||| f�nJ|dkrw|| f|_$|j||| f|
|f�n
|j%|�dS(
Nsauth-agent@openssh.coms!Incoming forward agent connectionR�s"Incoming x11 connection from %s:%dsforwarded-tcpips,Incoming tcp forwarded connection from %s:%ds+Rejecting "%s" channel request from server.sdirect-tcpips+Rejecting "%s" channel request from client.RkR�sSecsh channel %d (%s) opened.(&R�RRlR�R�R/RR�RRR
R�R�R�R~R R�t"check_channel_direct_tcpip_requesttcheck_channel_requestR!RCRR"R RRtRR�R
R�RRR�R�RR#torigin_addrR(R�RRRtinitial_window_sizeR�trejectt my_chanidR%torigin_porttserver_addrtserver_portR�Rt dest_portRnR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_parse_channel_open�s�
"cCsJ|j�}|j�}|j�}|jtdjtj|���dS(NsDebug msg: {0}(R�t
get_stringR/RR�R tsafe_string(R�Rtalways_displayRnR ((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�W scCsMz8|jj�||jkr,dgifS|j|SWd|jj�XdS(N(R�RR�R�R
(R�R?((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_get_subsystem_handler] s
(
s
aes128-ctrs
aes192-ctrs
aes256-ctrs
aes128-cbcsblowfish-cbcs
aes192-cbcs
aes256-cbcs3des-cbcs
arcfour128s
arcfour256(s
hmac-sha2-256s
hmac-sha2-512shmac-md5shmac-sha1-96shmac-md5-96s hmac-sha1(sssh-rsasssh-dss(sdiffie-hellman-group1-sha1sdiffie-hellman-group14-sha1s"diffie-hellman-group-exchange-sha1s$diffie-hellman-group-exchange-sha256(snoneN(NN(�R�t
__module__t__doc__tobjectR�R�R�tparamikot__version__R�R�R�RsRNt supported_key_format_identifiersR3R�R_RtAESRtCTRtBlowfishtCBCt TripleDEStARC4R�R�RRRRR�RMR:RzR=R>R;R<R@RAR?R�R8R9R�R�R�R5R6RlR~R|R�R�R�R�R�R�R�R�tstaticmethodR�R�R�R�R�R�RRR�RRR R%R'R)RR2ReR�RBR�RCRERFR9R8RMRYR6R7RZR[R\R^RaRbRYR/RpRRrRtRRwRyR}R�R�R�R�RRRR�R�R�R�R�R&R�RRR
RR�RRRRR"R-R�R1RR$R%R&R'R(R)RR�Rt_request_successR*t_request_failedR+t_feedR,t_feed_extendedR-t_window_adjustR.t_handle_requestR/t_handle_eofR0t
_handle_closeR1R�(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR\Us�
�
7A (
V- %K
O/3
& �
' + p ! ^
R�cBs�eZdZdZd�Zd�Zd�Zed��Zej d��Zed��Z
e
j d��Z
ed ��Zej d
��Zed��Zej d��Zed
��Z
e
j d��Z
RS(s:
Simple object containing the security preferences of an ssh transport.
These are tuples of acceptable ciphers, digests, key types, and key
exchange algorithms, listed in order of preference.
Changing the contents and/or order of these fields affects the underlying
`.Transport` (but only if you change them before starting the session).
If you try to add an algorithm that paramiko doesn't recognize,
``ValueError`` will be raised. If you try to assign something besides a
tuple to one of the fields, ``TypeError`` will be raised.
t
_transportcCs
||_dS(N(RG(R�t transport((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR|� scCsdt|j�S(sP
Returns a string representation of this object, for debugging.
s!<paramiko.SecurityOptions for %s>(R5RG(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�� scCs�t|�tkr!t|�}nt|�tk rBtd��ntt|j|�j��}g|D]}||krg|^qg}t|�dkr�td��nt |j||�dS(Nsexpected tuple or listisunknown cipher(
RrR�Rst TypeErrorRdRGR�Rpt
ValueErrorR�(R�R?torigR(tpossibletnt forbidden((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt_set� s%cCs
|jjS(sSymmetric encryption ciphers(RGR�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytciphers� scCs|jdd|�dS(NR�R�(RO(R�R(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRP� scCs
|jjS(s Digest (one-way hash) algorithms(RGR�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytdigests� scCs|jdd|�dS(NR�R�(RO(R�R(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRQ� scCs
|jjS(sPublic-key algorithms(RGR3(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt key_types� scCs|jdd|�dS(NR3Rz(RO(R�R(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRR� scCs
|jjS(sKey exchange algorithms(RGR�(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�� scCs|jdd|�dS(NR�R�(RO(R�R(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�� scCs
|jjS(sCompression algorithms(RGR_(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pytcompression� scCs|jdd|�dS(NR_R�(RO(R�R(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRS� s(R�R2R3t __slots__R|R�ROtpropertyRPtsetterRQRRR�RS(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�} s R�cBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs"tj�|_tj�|_dS(N(R*tWeakValueDictionaryt_mapRzR�t_lock(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR|� scCs3|jj�z||j|<Wd|jj�XdS(N(RYRRXR
(R�RR�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR
� s
cCs9|jj�z|jj|d�SWd|jj�XdS(N(RYRRXRR�R
(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR� s
cCsH|jj�z&y|j|=Wntk
r1nXWd|jj�XdS(N(RYRRXR�R
(R�R((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyRq� s
cCs9|jj�zt|jj��SWd|jj�XdS(N(RYRR�RXR�R
(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�� s
cCs3|jj�zt|j�SWd|jj�XdS(N(RYRRpRXR
(R�((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt__len__� s
(R�R2R|R
RRqR�RZ(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyR�� s
(�R3t
__future__RR!RtR�RzR�R*thashlibRRRRtcryptography.hazmat.backendsRt&cryptography.hazmat.primitives.ciphersRRRR5R tparamiko.auth_handlerR
tparamiko.ssh_gssRtparamiko.channelRtparamiko.commonR
RRRRRRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6R7tparamiko.compressR8R9tparamiko.dsskeyR:tparamiko.kex_gexR;R<tparamiko.kex_group1R=tparamiko.kex_group14R>tparamiko.kex_gssR?R@RARBtparamiko.messageRCtparamiko.packetRDREtparamiko.primesRFtparamiko.py3compatRGRHRIRJRKRLtparamiko.rsakeyRMtparamiko.ecdsakeyRNtparamiko.serverROtparamiko.sftp_clientRPtparamiko.ssh_exceptionRQRRRSRTt
paramiko.utilRURVRWRXR[tatexittregisterR{R\R4R�R�(((s6/usr/lib/python2.7/site-packages/paramiko/transport.pyt<module>sb"�
"."
���������1R |