_e[c@sdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z ddlmZddlmZmZmZddlZddlmZddlmZdd lmZdd lmZdd lmZmZmZm 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@mAZAmBZBmCZCmDZDmEZEmFZFmGZGdd lHmIZImJZJdd lKmLZLddlMmNZNddlOmPZPmQZQddlRmSZSddlTmUZUddlVmWZWmXZXmYZYddlZm[Z[m\Z\m]Z]ddl^m_Z_ddl`maZambZbddlcmdZdddlemfZfmgZgmhZhmiZimjZjmkZkddllmmZmddlnmoZoddlpmqZqddlrmsZsddltmuZumvZvmwZwmxZxddlymzZzm{Z{m|Z|gZ}dZ~ddlZeje~deje{fd YZd!efd"YZd#efd$YZdS(%s Core protocol implementation i(tprint_functionN(tmd5tsha1tsha256tsha512(tdefault_backend(t algorithmstCiphertmodes(tutil(t AuthHandler(tGSSAuth(tChannel(+t xfffffffftcMSG_CHANNEL_OPENt cMSG_IGNOREtcMSG_GLOBAL_REQUESTtDEBUGt MSG_KEXINITt MSG_IGNOREtMSG_DISCONNECTt MSG_DEBUGtERRORtWARNINGtcMSG_UNIMPLEMENTEDtINFOt cMSG_KEXINITt cMSG_NEWKEYSt MSG_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(t Ed25519Key(tKexGext KexGexSHA256(t KexGroup1(t KexGroup14(t KexNistp256t KexNistp384t KexNistp521(t KexGSSGext KexGSSGroup1t KexGSSGroup14(tMessage(t PacketizertNeedRekeyException(t ModulusPack(t string_typestlongtbyte_ordtbtinputtPY2(tRSAKey(tECDSAKey(tServerInterface(t SFTPClient(t SSHExceptiontBadAuthenticationTypetChannelExceptiontProxyCommandFailure(tretry_on_signaltClosingContextManagert clamp_valuecCsxtD]}|jqWdS(N(t_active_threadst stop_thread(tthr((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_join_lingering_threadsPs t Transportc BseZdZeZeZdZdjej Z dZ dZ dZ dZdZdZiiejd"6ejd#6d$d%6d$d&6d6iejd"6ejd#6d$d%6d'd&6d6iejd"6ejd#6d$d%6d(d&6d6iejd"6ejd#6d)d%6d$d&6d 6iejd"6ejd#6d$d%6d$d&6d6iejd"6ejd#6d$d%6d'd&6d6iejd"6ejd#6d$d%6d(d&6d6iejd"6ejd#6d)d%6d'd&6d 6Ziied"6d*d+6d 6ied"6d,d+6d6ied"6d(d+6d 6ied"6d-d+6d 6ied"6d$d+6d6ied"6d,d+6d6Zi ed6ed.6ed6ed/6e d6e d06e d6e d16e d6e d26e!d6e!d36Z"i e#d6e$d6e%d6e&d6e'd 6e(d6e)d6e*d6e+d6e,d6Z-ie.e/fd46e.e/fd56dd!6Z1dZ2d6Z3e4e5e6e7d7Z8d8Z9d9Z:d:Z;e7e7d;Z<ddd<Z=ddd=Z>d>Z?d?Z@eAdd@ZBdAZCdBZDdCZEddddDZFddEZGdFZHdGZIddddddHZJddIZKdJZLdKZMddLZNdMZOdNZPde7dOZQddPZRddQddde6e6e7e7dR ZSdSZTdTZUdUZVdVZWdWZXdXZYde7dYZZddZZ[dQd[Z\ddQd\Z]d]Z^d^Z_d_Z`d`ZadaZbdbZce7dcZdddZedeZfdfZgdgZhdhZidiZjdjZkdkZldlZmdmZndnZodoZpdpZqdqZrdrZsdsZtdtZuduZvdvZwdwZxdxZydyZzdzZ{d{Z|d|Z}d}Z~d~ZdZdZdZdZdZdZdZdZdZdZdZiee6ee6ee6ee6ee6ee6ee6eze6Zieje6eje6eje6eje6eje6eje6eje6eje6ZRS(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.0s paramiko_{}s aes128-ctrs aes192-ctrs aes256-ctrs aes128-cbcs aes192-cbcs aes256-cbcs blowfish-cbcs3des-cbcs hmac-sha2-256s hmac-sha2-512s hmac-sha1shmac-md5s hmac-sha1-96s hmac-md5-96s ssh-ed25519secdsa-sha2-nistp256secdsa-sha2-nistp384secdsa-sha2-nistp521sssh-rsasssh-dsssecdh-sha2-nistp256secdh-sha2-nistp384secdh-sha2-nistp521s$diffie-hellman-group-exchange-sha256s"diffie-hellman-group-exchange-sha1sdiffie-hellman-group14-sha1sdiffie-hellman-group1-sha1s%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==s)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==s(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==tnonetclasstmodeis block-sizeskey-sizeii iitsizei i@sssh-rsa-cert-v01@openssh.comsssh-dss-cert-v01@openssh.coms(ecdsa-sha2-nistp256-cert-v01@openssh.coms(ecdsa-sha2-nistp384-cert-v01@openssh.coms(ecdsa-sha2-nistp521-cert-v01@openssh.coms ssh-ed25519-cert-v01@openssh.comszlib@openssh.comtzlibg?cst|_d|_ttrjdd}|d|_t|dkre|ddfq|dt|dfnt t krx\|_d}t j t j t j}x|D]\} } } } } | t jkr| }t j |t jytfdWn"t jk rT}t|}qYXPqqWtdj|ntjj||jt|_|jj|jt|_d|jd |j|_ d |_!d |_"|_#d|_$|_%d|_&|_'d|_(|_)d|_*d|_+d|_,||_-t|_.d|_/d|_0|j-rt1d ||_/|j2|j3|_3nd|_4d|_5d|_6t|_7t|_8t|_9t |_:tj;|_<t=|_>i|_?i|_@d|_A||_B||_Cd|_Dd|_Ed|_Fd|_GtjH|_Itj;|_Jd |_Kd |_LtMjN|jL|_O|jjP|jOd|_Qd|_Rd|_Sd|_Td|_Ud|_Vt|_Wd|_Xi|_Yg|_Ztj[|j<|_\i|_]dS(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 familycsjfS(N(tconnect((thostnametporttsock(s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytEssUnable to connect to {}: {}sSSH-t-ts gssapi-keyexg>@sparamiko.transportiiN(^tFalsetactivetNoneRgt isinstanceRJtsplittlentintttypettupletsockett getaddrinfot AF_UNSPECt SOCK_STREAMRXterrortstrRTtformatt threadingtThreadt__init__t setDaemontTrueRit settimeoutt_active_check_timeoutRGt packetizert _PROTO_IDt _CLIENT_IDt local_versiontremote_versiont local_ciphert remote_ciphertlocal_kex_inittremote_kex_initt local_mact remote_mactlocal_compressiontremote_compressiont session_idt host_key_typethost_keyt use_gss_kext gss_kex_usedt kexgss_ctxttgss_hostR t_preferred_gsskext_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_logt auth_handlertglobal_responsetcompletion_eventtbanner_timeoutthandshake_timeoutt auth_timeoutt server_modet server_objecttserver_key_dicttserver_acceptst Conditiontserver_accept_cvtsubsystem_table(tselfRiRRtgss_kextgss_deleg_credsthltreasont addrinfostfamilytsocktypetprotot canonnametsockaddrtafte((RgRhRis6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs2                                             cCsttt|t@}dj|}|jsA|d7}n|jdkr~|dj|j|j|jdd7}n|jr|djt |j 7}n |j r|d7}n |d 7}|d 7}|S( sP Returns a string representation of this object, for debugging. s( thexRKtidR R|RnRt _cipher_infotis_authenticatedRrRR(Rtid_tout((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt__repr__s          cCs|jj|jdS(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(Ritclose(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytatforks 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/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytget_security_optionsscCsS|s dS|dkr"|j}n|rF|dk rFtj|}n||_dS(s Normalize/canonicalize ``self.gss_host`` depending on various factors. :param str gss_host: The explicitly requested GSS-oriented hostname to connect to (i.e. what the host's name is in the Kerberos database.) Defaults to ``self.hostname`` (which will be the 'real' target hostname and/or host portion of given socket object.) :param bool trust_dns: Indicates whether or not DNS is trusted; if true, DNS will be used to canonicalize the GSS hostname (which again will either be ``gss_host`` or the transport's default hostname.) (Defaults to True due to backwards compatibility.) :param bool gssapi_requested: Whether GSSAPI key exchange or authentication was even requested. If not, this is a no-op and nothing happens (and ``self.gss_host`` is not set.) (Defaults to True due to backwards compatibility.) :returns: ``None``. N(RoRgRvtgetfqdnR(RRt trust_dnstgssapi_requested((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt set_gss_hosts  cCst|_|dk r,||_|jdStj|_}|j|dk retj|nd}x~tr|jd|js|j }|dk r|nt dn|j s|dk rntj|krnPqnqnWdS(s| 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 ` or `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.( RRnRoRtstartR}Rttimetwaitt get_exceptionRTtis_set(Rteventttimeouttmax_timeR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt start_clients$#     "       cCs|dkrt}nt|_||_t|_|dk rV||_|jdStj |_}|jx`tr|j d|js|j }|dk r|nt dn|j rvPqvqvWdS(sp 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 negotiation 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.(RoRRRRRRnRRR}RRRRTR(RRtserverR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt start_server)s(*                cCs||j|jtk 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( RIR_t _modulus_packRotinsertt read_fileRtIOErrorRm(tfilenamet file_listtfn((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytload_server_modulis      cCsR|js dS|jx't|jjD]}|jq-W|jjdS(sP Close this session, and any open channels that are tied to it. N(RnR\tlistRtvaluest_unlinkRiR(Rtchan((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs   cCs*|j s|j r#tdn|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(RnRRTR(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytget_remote_server_keys 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 (Rn(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt is_activescCs|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. tsessiont window_sizetmax_packet_sizeR(t open_channel(RRRR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt open_sessions cCs|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(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytopen_x11_channelscCs |jdS(sB 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/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytopen_forward_agent_channels cCs|jd||S(sC 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(RRt dest_addr((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytopen_forwarded_tcpip_channels c Cs|jstdn|dkr*dn|}|jjzh|j|}|j|}|j}t}|j t |j ||j ||j ||j ||dks|dkr|j |d|j |d|j |d|j |dn1|dkrD|j |d|j |dnt |} |jj|| tj|j|<} t|j|<| j|| j||Wd|jjX|j|tj} xtrV| jd |js|j} | dkrtd } n| n| jr.Pq| |tjkrtd qqW|jj|} | dk ry| S|j} | dkrtd } n| dS( ss 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-tcpips direct-tcpipiiRNg?sUnable to open channel.sTimeout opening channel.(RnRTRoRtacquiret_sanitize_window_sizet_sanitize_packet_sizet _next_channelRFtadd_byteRt add_stringtadd_intR RtputR}RRRRt_set_transportt _set_windowtreleaset_send_user_messageRRRRtget( RtkindRRRRRtchanidtmRRtstart_tsR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR+sb*                         csjstdnt|}jd||fdt}|dkr]tdn|dkrx|j}n|dkrfd}|}n|_|S(s 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-forwardRsTCP forwarding request deniedicsj|dS(N(t_queue_incoming_channel(tchannelRtdest_addr_port(R(s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytdefault_handlersN(RnRTRstglobal_requestRRotget_intR(RtaddressRhthandlertresponseR((Rs6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytrequest_port_forwards!       cCs6|js dSd|_|jd||fdtdS(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(RnRoRRR(RR Rh((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytcancel_port_forwards  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 (RStfrom_transport(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytopen_sftp_clients cCsit}|jt|dkrBttjddd}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( RFR RRoRLtosturandomt add_bytesR(Rt byte_countR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt send_ignores    cCstj|_|jxftr|jjd|jsk|j}|dk r\|nt dn|jj rPqqWdS(sK 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( R}RRt_send_kex_initRRRnRRoRTR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytrenegotiate_keyss       cCs,tj|d}|jj||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|jddtS(Nskeepalive@lag.netR(RRm(tx((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_request sN(tweakreftproxyRt set_keepalive(RtintervalR/((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR2s cCs|rtj|_nt}|jt|j||j||dk rd|j |n|j t dj ||j ||sdSx:tr|jjd|jsdS|jjrPqqW|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 "{}"g?N(R}RRRFR RRt add_booleanRotaddt_logRR|RRRRnRR(RRtdataRR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs&        cCs|jjznt|jdkr:|jjd}n@|jj|t|jdkrt|jjd}nd}Wd|jjX|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( RR RrRtpopRRRoR(RRR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytaccept6s  Rlc Cs|d k r!|jg|_n|jd|d| d|p?||j|d k r9| r9|j} | j|jks| j|jkr|jtd|jtdj |jt |j|jtdj | jt | jt dn|jtdj |jn|d k s]|d k s]|s]|r|r|jtd|j ||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. :param gss_trust_dns: Indicates whether or not the DNS is trusted to securely canonicalize the name of the host being connected to (default ``True``). :raises: `.SSHException` -- if the SSH2 negotiation fails, the host key supplied by the server is incorrect, or authentication fails. .. versionchanged:: 2.3 Added the ``gss_trust_dns`` argument. RRRsBad host key from serversExpected: {}: {}sGot : {}: {}sHost key verified ({})s,Attempting GSS-API auth... (gssapi-with-mic)s)Attempting GSS-API auth... (gssapi-keyex)sAttempting public-key auth...sAttempting password auth...N(RoRt_preferred_keysRRRtasbytesR6RR|treprRTtauth_gssapi_with_micRtauth_gssapi_keyextauth_publickeyt auth_password( RthostkeytusernametpasswordtpkeyRtgss_authRRt gss_trust_dnsR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRfOsB<     $ cCs<|jjz|j}d|_|SWd|jjXdS(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(RR RRoR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs   cOs<z'|jj|||f|j|tj}n|}t||_|jj|||dk rygSy|jj |SWnlt k r}| sd|j krny#fd}|j ||SWqtk r|qXnXdS(s 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!tdnt|dkr7gSgS(NisFallback authentication failed.i(RrRT(ttitlet instructionstfields(RC(s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR!ls N( RnRRTRoR}RR RR@RORUt allowed_typestauth_interactive(RRBRCRtfallbackRPRR!((RCs6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR@(s&/    cCs|j s|j r#tdn|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( RnRRTRoR}RR RR?RO(RRBRRRP((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR?{s#  cCsg|j s|j r#tdntj}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( RnRRTR}RR RRURO(RRBR!t submethodsRP((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRUs+  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|jn|r8t|jnx:|D]2\}}t|jdd|jtq?W|S(Ntendt (tprinttstriptappendRN(RQRRt prompt_listtanswerstpromptt show_input((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR!s(RU(RRBR!RW((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytauth_interactive_dumbs cCsg|j s|j r#tdntj}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) :raises: `.BadAuthenticationType` -- if gssapi-with-mic isn't allowed by the server (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( RnRRTR}RR RR=RO(RRBRRRP((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR=s  cCsa|j s|j r#tdntj}t||_|jj|||jj|S(sZ 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( RnRRTR}RR RR>RO(RRBRP((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR>s  cCs2||_tj||_|jj|jdS(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(RR RRRR(RRG((s6/tmp/pip-install-KP2Jbq/paramiko/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/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytget_log_channel6scCs|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(Rt set_hexdump(Rthexdump((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRd@s cCs |jjS(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 (Rt get_hexdump(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRfLs 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.comRdR`N(szlib@openssh.comszlibsnone(snone(t_preferred_compression(Rtcompress((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytuse_compressionWs  cCs,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. t getpeernametunknowniN(sunknowni(tgetattrRiRo(Rtgp((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRjhs  cCst|_|jjtrQx~|jrM|tjk rM|jdqWnLxI|jr|tjk r|j j r|jj r|jdqTWdS(Ni g?( RmRnRRROtis_aliveR}tcurrent_threadtjoinRit_closedtclosed(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR\ys  !   cGsVtt|tr<x:|D]}|jj||qWn|jj|||dS(N(t issubclassRtRRtlog(RtleveltmsgtargsR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR6s cCs|jS(s0used by KexGex to find primes for group exchange(R(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_get_modulus_packscCs]|j}x9|jj|dk rD|jdd@|_|j}q W|jdd@|_|S(syou are holding the lockiiN(RRRRo(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR s   cCs|jj|dS(s?used by a Channel to remove itself from the active channel listN(Rtdelete(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_unlink_channelscCs|jj|dS(N(Rt send_message(RR7((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt _send_messagescCstj}xtr|jjd|jsB|jtddS|jj|jj rbPn|jj tj||j krt dqqWz|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(RRRRRnR6RRR RRRRTR|(RR7R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs     cCs1||_||_|jdkr-||_ndS(sR Used by a kex obj to set the K (root key) and H (exchange hash). N(RRRRo(Rtkth((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_set_K_Hs  cGst||_dS(sW Used by a kex obj to register the next packet type it expects to see. N(RuR(Rtptypes((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_expect_packetscCsz|j|jt|}|dkr7tdn|j|jt|smtdj|jn||_dS(NsUnknown host key types#Signature verification ({}) failed.( t _key_infoRRFRoRTtverify_ssh_sigRR|R(RRtsigR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt _verify_keys  c Cslt}|j|j|j|j|jt||j|jt|j dd}dj |j j j |}|dkrt}|d7}nt|ds|jt|t|dtn||jj}}xxt||krct}|j|j|j|j|j|||jj}||7}||7}qW|| S(s0id is 'A' - 'F' for the various keys used by ssht hash_algos&kex engine {} specified hash_algo {!r}s, falling back to sha1t_logged_hash_selectionN(RFt add_mpintRR)RR RMRRlRRoR|t __class__t__name__RthasattrR6RtsetattrRR;tdigestRr( RRtnbytesRRthash_select_msgRtsofarR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt _compute_keys0      cCs||jkr"td|n]t|j|d||j|d|dt}||jkru|jS|jSdS(NsUnknown client cipher RaRbtbackend(RRTRRt_ENCRYPTt encryptort decryptor(RRGRtivt operationtcipher((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt _get_ciphers  cs4|dkr'fd}|_n |_dS(Ncsj|dS(N(R(R(R(s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs(RoR(RR!R((Rs6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_set_forward_agent_handlers  cs4|dkr'fd}|_n |_dS(Ncsj|dS(N(R(Rt src_addr_port(R(s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs(RoR(RR!R((Rs6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_set_x11_handlers  cCsC|jjz!|jj||jjWd|jjXdS(N(RR RR\RtnotifyR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs  cCs(|dkr|j}ntt|tS(N(RoRRZR2R4(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR  s  cCs(|dkr|j}ntt|tS(N(RoRRZR3R4(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR %s  cCs|j s"|tks"|jr&dSt}|tkrK|jtnh|tkr|j }|j }|jt |j ||j t |jd|jdn|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. RltenN(RR7RRoRFR$R RR)tget_textRR"RR R(RtptypetmessagetreplyRR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_ensure_authed*s            c Cs8t|_tj|ttt|t@}|jrW|jt dj |n|jt dj |yyK|j j t |jd|jt dj |j|j|j j|j|j|jtx|jr|j jr|j r|jny|j j\}}Wntk rDqnX|tkrWqn<|tkrt|j|Pn|tkr|j|qnt|j dkr||j krt!dj |j |nt"|_ |dkr|dkr|j#j$||qqn||j%krc|j&||}|rL|j'|q|j%|||nI||j(kr|j)}|j*j+|}|dk r|j(|||q||j-kr|jt d j |q|jt.d j |Pn|j/dk rZ||j/j%krZ|j/j%|}||j/|t|j dkrqqnRd j |}|jt0|t1} | j2t3| j4|j5|j'| |j j6qWWnYt!k r } |jt.d t7| |jt.t8j9| |_:nt;k r7} |jt d | |_:nt<j=k r} t>| j?t"kr| j?rdj | j?d| j?d} qt7| pt@| } n | j?} |jt.d| | |_:nLtAk r} |jt.dt7| |jt.t8j9| |_:nXtjB|x'tC|j*jDD]}|jEq=W|jrtF|_|j jG|jHdk r|jHjIn|j/dk r|j/jJnx!|jKjDD]} | jIqWz|jLjM|jNjOWd|jLjPXn|jQjGWn|jjRdk r4q4nXdS(Ns!starting thread (server mode): {}s!starting thread (client mode): {}s sLocal version/idstring: {}is$Expecting packet from {!r}, got {:d}ii)s&Ignoring message for dead channel {:d}s(Channel request for unknown channel {:d}sOops, unhandled type {:d}s Exception: sEOF in transport threads {} ({:d})isSocket exception: sUnknown exception: (StsysR[R\RRKRR RR6RR|Rt write_allRMRt _check_bannertstart_handshakeRR,RRRnt need_rekeyRt read_messageRHRRt_parse_disconnectRt _parse_debugRrRRTRuRt parse_nextt_handler_tableRR|t_channel_handler_tableRRRRoRRRRRFR RRtseqnotcomplete_handshakeR{R t tb_stringsRtEOFErrorRvRzRtRwR<t ExceptiontremoveRRRRmRRtsettabortRRR RRRRitmodules( RttidRRt error_msgRRR!terrRvRtemsgR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytrunPs                         #        cCsRdj|}||kr(||7}n|dj||7}|jt|dS(Ns {} agreed: slocal={}, remote={}(R|R6R(RtwhichtlocaltremoteRv((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_log_agreements   cCsi|jjz|jjWd|jjX|jdkrK|jn|j||j j dS(N( RR RtclearRRRoR,t_parse_kex_initRt start_kex(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_negotiate_keyss   c CsxtdD]}|dkr+|j}nd}y|jj|}Wn<tk r]n)tk r}tdt|nX|d dkrPn|jt d|q W|d dkrtd|d n||_ |jt d j ||j d }|dkr#|| }n|j d d}t|d krVtdn|d}|d}|dkr|dkrd}t|j |ndj ||}|jt|dS(Nidiis!Error reading SSH protocol bannerisSSH-sBanner: s!Indecipherable protocol version "t"sRemote version/idstring: {}RYRkisInvalid SSH banneris1.99s2.0s(Incompatible version ({} instead of 2.0)s!Connected (version {}, client {})(trangeRRtreadlineRWRRTR{R6RRR|tfindRqRrR( RtiRtbufRtsegstversiontclientRv((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRs>        cCs|jjz|jjWd|jjXt|_t|_|j r d}g|j D]}|j |rZ|^qZ}|j dkrt|dkrg|jjD]}|j |s|^q}||j_nttt|jjj|j}n |j}t}|jt|jtjd|j|j |j||j|j|j|j|j|j|j|j|j|j |j|j |j!t"|j!t"|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((RR RRRRmRRRRRt startswithRRoRrRtkexRtfilterRtkeyst __contains__R:RFR RR)R'R(tadd_listt_preferred_cipherst_preferred_macsRgRtbytesR4RR;RR|(Rtmp_required_prefixR}tkex_mptpkextavailable_server_keysR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR,sJ     !      cCs|jd|j}|j}|j}|j}|j}|j}|j}|j} |j} |j} |j} |j|jtdt|dt|dt|dt|dt|dt|dt|d t| d t| d t| d t| |jrhtt |j j |} ntt |j |j } t | d krt dn|j| d ||_|jtdj| d |jr)tt t|jjj |j}tt |j |}ntt |j |j}t |d kret dn|d |_|jr|jdkrt dn|jd|d |d |jrtt |jj |}tt |jj |}n6tt |j |j}tt |j |j}t |d ksSt |d krbt dn|d |_|d |_|jdd|jd|j|jrtt |jj |}tt |jj |}n6tt |j |j}tt |j |j}t |d ks7t |d krFt dn|d |_|d |_|jdd|jd|j|jrtt |jj |}tt |jj | }n6tt |j |j}tt | j |j}t |d kst |d krBd}t |j|||jn|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: {}s.Incompatible ssh peer (no acceptable host key)s;Incompatible ssh peer (can't match requested host key type)tHostKeys/Incompatible ssh server (no acceptable ciphers)RRRs,Incompatible ssh server (no acceptable macs)tMACsBIncompatible ssh server (no acceptable compression) {!r} {!r} {!r}t Compression($t get_bytestget_listt get_booleanRR6RR{RRRRRRrRTt _kex_infoRR|RRR:RRRoRRRRRRRRgRRRt get_so_farR(RRt 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_listt kex_followst agreed_kexRt agreed_keystagreed_local_cipherstagreed_remote_cipherstagreed_remote_macstagreed_local_macstagreed_remote_compressiontagreed_local_compressionRv((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRSs                      $   $           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 |j d }|dk r|j d ksZ|jr|jtd |j j|ndS(sMswitch on newly negotiated encryption parameters for inbound traffics block-sizetAtCskey-sizetBtDRcRatEtFiszlib@openssh.coms$Switching on inbound compression ...N(RRRRRt_DECRYPTt _mac_infoRt digest_sizeRtset_inbound_ciphert_compression_infoRRoRR6Rtset_inbound_compressor( Rt block_sizetIV_intkey_intenginetmac_sizet mac_enginetmac_keyt compress_in((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_activate_inbounds.     c Cst}|jt|j||j|jd}|jru|jd|}|jd|j|jd}n2|jd|}|jd|j|jd}|j|j|||j }|j |j d}|j |j d}|jr|jd |j }n|jd |j }|jj d } |jj|||||| |j|jd } | dk r|jd ks|jr|jtd|jj| n|jjst|_n|jtdS(sNswitch on newly negotiated encryption parameters for outbound traffics block-sizeRRskey-sizeRRRcRaRRs-ctriszlib@openssh.coms%Switching on outbound compression ...N(RFR RR|RRRRRRRRRtendswithRtset_outbound_cipherRRRoRR6Rtset_outbound_compressorRRmRRR( RRRtIV_outtkey_outRRRRtsdctrt compress_out((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_activate_outbound s<         cCst|_|jdkrR|j|jd}|jtd|jj|n|jdkr|j|jd}|jtd|jj |ndS(Nszlib@openssh.comis%Switching on outbound compression ...is$Switching on inbound compression ...( RRRRR6RRR RR(RRR ((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt _auth_triggerD s cCs|jtd|jd|_|_d|_d|_|jrf|j dkrft ||_ n|j s{t |_ n|j dk r|j jn|jjst|_n|jjz|jjWd|jjXdS(NsSwitch to new keys ...(R6RR RoRRRRRRR RRRRRRRmRRR RR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_newkeysP s$       cCs8|j}|j}|jtdj||dS(NsDisconnect (code {:d}): {}(RRR6RR|(RRtcodetdesc((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRj s  c Csy|j}|jtdj||j}|js\|jtdj|t}n|dkr|j}|j}|jj ||}|r|f}qnU|dkr|j}|j}|jj ||t }n|jj ||}d}t |tkr&|}t }n|rut}|rX|jt|j|n |jt|j|ndS(NsReceived global request "{}"s*Rejecting "{}" global request from server.s tcpip-forwardscancel-tcpip-forward((RR6RR|RRRmRRtcheck_port_forward_requesttcancel_port_forward_requestRtcheck_global_requestRtRuRFR RR5RR|( RRRt want_replytokR RhtextraRv((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_global_requesto s>               cCs<|jtd||_|jdk r8|jjndS(NsGlobal request successful.(R6RRRRoR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_request_success s cCs<|jtdd|_|jdk r8|jjndS(NsGlobal request denied.(R6RRoRRR(RR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_request_failure s cCs|j}|j}|j}|j}|jj|}|dkrb|jtddS|jjz]|j||||jt dj |||j kr|j |j |j |=nWd|jj XdS(Ns%Success for unrequested channel! [??]sSecsh channel {:d} opened.(RRRRoR6RRR t_set_remote_channelRR|RRR(RRRt server_chanidtserver_window_sizetserver_max_packet_sizeR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_channel_open_success s$       cCs|j}|j}|j}|jtj|d}|jtdj||||jjzet |||_ ||j kr|j j |||j kr|j |j|j |=qnWd|jjXdS(Ns(unknown code)s&Secsh channel {:d} open FAILED: {}: {}(RRRRR6RR|RR RVRRRRyRR(RRRRt reason_strt reason_text((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_channel_open_failure s&     cCs|j}|j}|j}|j}t}|dkr|jdk r|jtd|jjz|j }Wd|jj Xn|dkr|j dk r|j}|j} |jtdj || |jjz|j }Wd|jj Xn|dkr|j dk r|j} |j} |j}|j} |jtdj || |jjz|j }Wd|jj Xn|js|jtdj |t}t} n|jjz|j }Wd|jj X|dkrl|j} |j}|j}|j} |jj||| f| |f} n|jj||} | tkr|jtd j |t}n|rt}|jt|j||j| |jd |jd |j|dSt|}|jjzZ|jj||t|j|<|j||j |j!|j"|j#|||Wd|jj Xt}|jt$|j||j||j|j!|j|j"|j||jtd j |||dkr)|j|no|dkrN|j ||| fnJ|dkr|| f|_%|j ||| f| | fn |j&|dS( Nsauth-agent@openssh.coms!Incoming forward agent connectionRs$Incoming x11 connection from {}:{:d}sforwarded-tcpips.Incoming tcp forwarded connection from {}:{:d}s+Rejecting "{}" channel request from server.s direct-tcpips+Rejecting "{}" channel request from client.RlRsSecsh channel {:d} ({}) opened.('RRRmRRoR6RRR R RRR|RRRR Rt"check_channel_direct_tcpip_requesttcheck_channel_requestR!RFR R"RRR|R RRRRRRRR R#t origin_addrR(RRRRtinitial_window_sizeRtrejectt my_chanidR*t origin_portt server_addrt server_portRRt dest_portRvR((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_parse_channel_open s                                                   cCsF|j|j}|j|jtdjtj|dS(Ns Debug msg: {}(Rt get_stringR6RR|R t safe_string(RRRv((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRG s   cCsMz8|jj||jkr,dgifS|j|SWd|jjXdS(N(RR RRoR(RRG((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_get_subsystem_handlerM s   (s aes128-ctrs aes192-ctrs aes256-ctrs aes128-cbcs aes192-cbcs aes256-cbcs blowfish-cbcs3des-cbc(s hmac-sha2-256s hmac-sha2-512s hmac-sha1shmac-md5s hmac-sha1-96s hmac-md5-96(s ssh-ed25519secdsa-sha2-nistp256secdsa-sha2-nistp384secdsa-sha2-nistp521sssh-rsasssh-dss(secdh-sha2-nistp256secdh-sha2-nistp384secdh-sha2-nistp521s$diffie-hellman-group-exchange-sha256s"diffie-hellman-group-exchange-sha1sdiffie-hellman-group14-sha1sdiffie-hellman-group1-sha1(s%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==s)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==s(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==(snoneN(NN(Rt __module__t__doc__tobjectRRRR|tparamikot __version__RRRR:RRRgRtAESRtCTRtBlowfishtCBCt TripleDESRRRRRRRPR:RQR;RR>R?R<R=RDRERCR@RARBRR8R9RoRRRR5R6RmRRRRRRRRRRt staticmethodRRRRRRRRRR#R$R&R+R-R2RR9RfRRJRRKRMRNR@R?RURaR=R>RbRcRdRfRiRjR\R6RxR RzR|RRRRRRRRRR R RRRRRR,RR RRRRRRRR$R'R2RR5RR$R%R&R'R(R)RRR t_request_successR*t_request_failedR+t_feedR,t_feed_extendedR-t_window_adjustR.t_handle_requestR/t _handle_eofR0t _handle_closeR1R(((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR_Ys                                 ";B  (      W 4    %  c    S 1 5                    & + 6 ' +   $     {          RcBseZdZdZdZdZdZedZej dZedZ e j dZ ed Z e j d Z ed Z e j d Z ed Z e j dZ 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(RI(Rt transport((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR{ scCsdj|jS(sP Returns a string representation of this object, for debugging. s#(R|RI(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR~ scCst|tkr!t|}nt|tk rBtdntt|j|j}g|D]}||krg|^qg}t|dkrtdnt |j||dS(Nsexpected tuple or listisunknown cipher( RtRRut TypeErrorRlRIRRrt ValueErrorR(RRGtorigR.tpossibletnt forbidden((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt_set s%cCs |jjS(sSymmetric encryption ciphers(RIR(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytciphers scCs|jdd|dS(NRR(RQ(RR.((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRR scCs |jjS(s Digest (one-way hash) algorithms(RIR(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytdigests scCs|jdd|dS(NRR(RQ(RR.((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRS scCs |jjS(sPublic-key algorithms(RIR:(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt key_types scCs|jdd|dS(NR:R(RQ(RR.((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRT scCs |jjS(sKey exchange algorithms(RIR(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR scCs|jdd|dS(NRR(RQ(RR.((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR scCs |jjS(sCompression algorithms(RIRg(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyt compression scCs|jdd|dS(NRgR(RQ(RR.((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRU s(RR6R7t __slots__RRRQtpropertyRRtsetterRSRTRRU(((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyRm s    RcBs>eZdZdZdZdZdZdZRS(cCs"tj|_tj|_dS(N(R0tWeakValueDictionaryt_mapR}Rt_lock(R((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pyR scCs3|jjz||j|tparamiko.kex_group14R?tparamiko.kex_ecdh_nistR@RARBtparamiko.kex_gssRCRDREtparamiko.messageRFtparamiko.packetRGRHtparamiko.primesRItparamiko.py3compatRJRKRLRMRNROtparamiko.rsakeyRPtparamiko.ecdsakeyRQtparamiko.serverRRtparamiko.sftp_clientRStparamiko.ssh_exceptionRTRURVRWt paramiko.utilRXRYRZR[R^tatexittregisterR~R_R8RR(((s6/tmp/pip-install-KP2Jbq/paramiko/paramiko/transport.pytsh      "  ."   Q