a °…bÅÜã@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;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKdd lLmMZMmNZNdd lOmPZPddlQmRZRddlSmTZTddlUmVZVmWZWddlXmYZYddlZm[Z[m\Z\ddl]m^Z^ddl_m`Z`maZambZbddlcmdZdmeZemfZfddlgmhZhddlimjZjmkZkddllmmZmddlnmoZompZpmqZqmrZrmsZsmtZtddlumvZvddlwmxZxddlymzZzddl{m|Z|ddl}m~Z~mZm€Z€mZm‚Z‚ddlƒm„Z„m…Z…m†Z†gZ‡d d!„Zˆddl‰Z‰e‰ Šeˆ¡Gd"d#„d#ej‹e…ƒZŒGd$d%„d%eƒZŽGd&d'„d'eƒZdS)(z Core protocol implementation é)Úprint_functionN)Úmd5Úsha1Úsha256Úsha512)Údefault_backend)Ú algorithmsÚCipherÚmodes)Úutil)Ú AuthHandler)ÚGSSAuth)ÚChannel)/Ú xffffffffÚcMSG_CHANNEL_OPENÚ cMSG_IGNOREÚcMSG_GLOBAL_REQUESTÚDEBUGÚ MSG_KEXINITÚ MSG_IGNOREÚMSG_DISCONNECTÚ MSG_DEBUGÚERRORÚWARNINGÚcMSG_UNIMPLEMENTEDÚINFOÚ cMSG_KEXINITÚ cMSG_NEWKEYSÚ MSG_NEWKEYSÚcMSG_REQUEST_SUCCESSÚcMSG_REQUEST_FAILUREÚCONNECTION_FAILED_CODEÚ'OPEN_FAILED_ADMINISTRATIVELY_PROHIBITEDÚOPEN_SUCCEEDEDÚcMSG_CHANNEL_OPEN_FAILUREÚcMSG_CHANNEL_OPEN_SUCCESSÚMSG_GLOBAL_REQUESTÚMSG_REQUEST_SUCCESSÚMSG_REQUEST_FAILUREÚMSG_CHANNEL_OPEN_SUCCESSÚMSG_CHANNEL_OPEN_FAILUREÚMSG_CHANNEL_OPENÚMSG_CHANNEL_SUCCESSÚMSG_CHANNEL_FAILUREÚMSG_CHANNEL_DATAÚMSG_CHANNEL_EXTENDED_DATAÚMSG_CHANNEL_WINDOW_ADJUSTÚMSG_CHANNEL_REQUESTÚMSG_CHANNEL_EOFÚMSG_CHANNEL_CLOSEÚMIN_WINDOW_SIZEÚMIN_PACKET_SIZEÚMAX_WINDOW_SIZEÚDEFAULT_WINDOW_SIZEÚDEFAULT_MAX_PACKET_SIZEÚHIGHEST_USERAUTH_MESSAGE_IDÚMSG_UNIMPLEMENTEDÚ MSG_NAMESÚ MSG_EXT_INFOÚ cMSG_EXT_INFO)ÚZlibCompressorÚZlibDecompressor)ÚDSSKey)Ú Ed25519Key)Ú KexCurve25519)ÚKexGexÚ KexGexSHA256)Ú KexGroup1)Ú KexGroup14ÚKexGroup14SHA256)ÚKexGroup16SHA512)Ú KexNistp256Ú KexNistp384Ú KexNistp521)Ú KexGSSGexÚ KexGSSGroup1Ú KexGSSGroup14)ÚMessage)Ú PacketizerÚNeedRekeyException)Ú ModulusPack)Ú string_typesÚlongÚbyte_ordÚbÚinputÚPY2)ÚRSAKey)ÚECDSAKey)ÚServerInterface)Ú SFTPClient)Ú SSHExceptionÚBadAuthenticationTypeÚChannelExceptionÚIncompatiblePeerÚProxyCommandFailure)Úretry_on_signalÚClosingContextManagerÚ clamp_valuecCstD] }| ¡qdS©N)Ú_active_threadsÚ stop_thread)Zthr©rhú9/tmp/pip-target-98j97qn4/lib/python/paramiko/transport.pyÚ_join_lingering_threadszsrjc@seZdZdZeƒZeƒZdZd e j ¡Z dZ dZ dZdZdZe ¡rLdeZd Zd Zejejd d d œejejd d d œejejd dd œejejd d d œejejd d d œejejd dd œejejdd d œdœZeddœeddœeddœeddœeddœeddœed dœeddœdœZ e!e!e!e!e!e!e"e"e#e#e#e#e#e#e$e$dœZ%e&e'e(e)e*e+e,e-e.e/e0e1dœ Z2e ¡rfee2d<e3e4fe3e4fddœZ5dZ6dZ7e8e9ddddfdd„Z:d d!„Z;eed?„ƒZLd@dA„ZMdBdC„ZNdDdE„ZOdÛdFdG„ZPdÜdHdI„ZQdJdK„ZRdLdM„ZSdÝdNdO„ZTdÞdPdQ„ZUdRdS„ZVdTdU„ZWdßdVdW„ZXdXdY„ZYdZd[„ZZdàd\d]„Z[dád^d_„Z\dâdadb„Z]dcdd„Z^dedf„Z_dgdh„Z`didj„Zadkdl„Zbdmdn„Zcdãdodp„Zddädqdr„Zedådsdt„Zfdædudv„Zgdwdx„Zhdydz„Zid{d|„Zjd}d~„Zkdd€„Zldd‚„Zmdçdƒd„„Znd…d†„Zod‡dˆ„Zpd‰dŠ„Zqd‹dŒ„ZrddŽ„Zsdd„Ztd‘d’„Zud“d”„Zvd•d–„Zwd—d˜„Zxd™dš„Zyd›dœ„Zzddž„Z{dŸd „Z|d¡d¢„Z}d£d¤„Z~d¥d¦„Zd§d¨„Z€d©dª„Zd«d¬„Z‚d­d®„Zƒd¯d°„Z„d±d²„Z…d³d´„Z†dèdµd¶„Z‡d·d¸„Zˆd¹dº„Z‰d»d¼„ZŠd½d¾„Z‹d¿dÀ„ZŒdÁd„ZdÃdÄ„ZŽdÅdÆ„ZdÇdÈ„ZdÉdÊ„Z‘dËdÌ„Z’dÍd΄Z“dÏdЄZ”dÑdÒ„Z•dÓdÔ„Z–dÕdÖ„Z—e˜ee™eŽešee›e‘eœe’ee“eže”eŸe•e e„i Z¡e¢e£j¤e¥e£j¦e§e£j¨e©e£jªe«e£j¬e­e£j®e¯e£j°e±e£j²iZ³dS)éÚ Transporta„ 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. ú2.0z paramiko_{})z aes128-ctrz aes192-ctrz aes256-ctrz aes128-cbcz aes192-cbcz aes256-cbcz3des-cbc)ú hmac-sha2-256ú hmac-sha2-512úhmac-sha2-256-etm@openssh.comúhmac-sha2-512-etm@openssh.comú hmac-sha1úhmac-md5ú hmac-sha1-96ú hmac-md5-96)ú ssh-ed25519úecdsa-sha2-nistp256úecdsa-sha2-nistp384úecdsa-sha2-nistp521ú rsa-sha2-512ú rsa-sha2-256ússh-rsaússh-dss) úecdh-sha2-nistp256úecdh-sha2-nistp384úecdh-sha2-nistp521údiffie-hellman-group16-sha512ú$diffie-hellman-group-exchange-sha256údiffie-hellman-group14-sha256ú"diffie-hellman-group-exchange-sha1údiffie-hellman-group14-sha1údiffie-hellman-group1-sha1)úcurve25519-sha256@libssh.org)ú%gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==ú)gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==ú(gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==©Únoneé)ÚclassÚmodeú block-sizeúkey-sizeéé éé)rÚsizeé é@)rqrsrmrornrprrrt)r{zssh-rsa-cert-v01@openssh.comrzz!rsa-sha2-256-cert-v01@openssh.comryz!rsa-sha2-512-cert-v01@openssh.comr|zssh-dss-cert-v01@openssh.comrvz(ecdsa-sha2-nistp256-cert-v01@openssh.comrwz(ecdsa-sha2-nistp384-cert-v01@openssh.comrxz(ecdsa-sha2-nistp521-cert-v01@openssh.comruz ssh-ed25519-cert-v01@openssh.com) r…r„rƒrr‚r€r‰rˆr‡r}r~rr†)NN©úzlib@openssh.comÚzlibr‹Nçš™™™™™¹?FTc sd|_d|_i|_tˆtƒr`ˆ dd¡}|d|_t|ƒdkrL|ddf‰n|dt|dƒf‰tˆƒt ur$ˆ\‰‰ˆ|_d} t   ˆˆt j t j ¡} | D]z\} } } }}| t j kr˜| }t   |t j ¡‰zt‡‡‡fdd „ƒWn0t jy }zt|ƒ} WYd}~q˜d}~00q$q˜td  ˆ| ¡ƒ‚tj |¡d |_ˆ|_|j |j¡tˆƒ|_d |jd |j|_d|_d|_ |_!d|_"|_#d|_$|_%d|_&|_'d|_(d|_)d|_*||_+d|_,d|_-d|_.|j+rìt/d|ƒ|_-|j0|j1|_1d|_2d|_3d|_4d|_5d|_6d|_7t ƒ|_8t 9¡|_:t;ƒ|_d|_?||_@||_Ad|_Bd|_Cd|_Dd|_Et F¡|_Gt 9¡|_Hd|_Id|_JtK L|jJ¡|_M|j N|jM¡d|_Od|_Pd|_Qd|_Rd|_Sd|_T|pÈi|_U||_Vd|_Wd|_Xi|_Yg|_Zt [|j:¡|_\i|_]dS)aœ 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) :param bool gss_kex: Whether to enable GSSAPI key exchange when GSSAPI is in play. Default: ``False``. :param bool gss_deleg_creds: Whether to enable GSSAPI credential delegation when GSSAPI is in play. Default: ``True``. :param dict disabled_algorithms: If given, must be a dictionary mapping algorithm type to an iterable of algorithm identifiers, which will be disabled for the lifetime of the transport. Keys should match the last word in the class' builtin algorithm tuple attributes, such as ``"ciphers"`` to disable names within ``_preferred_ciphers``; or ``"kex"`` to disable something defined inside ``_preferred_kex``. Values should exactly match members of the matching attribute. For example, if you need to disable ``diffie-hellman-group16-sha512`` key exchange (perhaps because your code talks to a server which implements it differently from Paramiko), specify ``disabled_algorithms={"kex": ["diffie-hellman-group16-sha512"]}``. :param bool server_sig_algs: Whether to send an extra message to compatible clients, in server mode, with a list of supported pubkey algorithms. Default: ``True``. .. versionchanged:: 1.15 Added the ``default_window_size`` and ``default_max_packet_size`` arguments. .. versionchanged:: 1.15 Added the ``gss_kex`` and ``gss_deleg_creds`` kwargs. .. versionchanged:: 2.6 Added the ``disabled_algorithms`` kwarg. .. versionchanged:: 2.9 Added the ``server_sig_algs`` kwarg. FNú:érézNo suitable address familycsˆ ˆˆf¡Sre)Úconnectrh©ÚhostnameÚportÚsockrhriÚ³óz$Transport.__init__..zUnable to connect to {}: {}TúSSH-ú-Úz gssapi-keyexg>@zparamiko.transportéé)^Úactiver¡Úserver_extensionsÚ isinstancerSÚsplitÚlenÚintÚtypeÚtupleÚsocketÚ getaddrinfoÚ AF_UNSPECÚ SOCK_STREAMrbÚerrorÚstrr]ÚformatÚ threadingÚThreadÚ__init__Údaemonr£Ú settimeoutÚ_active_check_timeoutrPÚ packetizerÚ _PROTO_IDÚ _CLIENT_IDÚ local_versionÚremote_versionÚ local_cipherÚ remote_cipherÚlocal_kex_initÚremote_kex_initÚ local_macÚ remote_macÚlocal_compressionÚremote_compressionÚ session_idÚ host_key_typeÚhost_keyZ use_gss_kexÚ gss_kex_usedZ kexgss_ctxtÚgss_hostr Ú_preferred_gsskexÚ_preferred_kexÚ kex_engineÚHÚKÚinitial_kex_doneÚin_kexÚ authenticatedÚ_expected_packetÚLockÚlockÚ ChannelMapÚ _channelsÚchannel_eventsÚ channels_seenÚ_channel_counterÚdefault_max_packet_sizeÚdefault_window_sizeÚ_forward_agent_handlerÚ _x11_handlerÚ _tcp_handlerÚsaved_exceptionÚEventÚ clear_to_sendÚclear_to_send_lockÚclear_to_send_timeoutÚlog_namer Ú get_loggerÚloggerÚset_logÚ auth_handlerÚglobal_responseÚcompletion_eventÚbanner_timeoutÚhandshake_timeoutZ auth_timeoutÚdisabled_algorithmsÚserver_sig_algsÚ server_modeÚ server_objectÚserver_key_dictÚserver_acceptsÚ ConditionÚserver_accept_cvÚsubsystem_table)Úselfr£rãrâÚgss_kexÚgss_deleg_credsrõröZhlÚreasonÚ addrinfosÚfamilyÚsocktypeÚprotoÚ canonnameÚsockaddrÚafÚerhr rir¼Cs®V     ÿ  ÿ           zTransport.__init__cs(tˆd ˆ¡ƒ}t‡‡fdd„|DƒƒS)Nz _preferred_{}c3s$|]}|ˆj ˆg¡vr|VqdSre)rõÚget©Ú.0Úx©rþÚtype_rhriÚ sþz.Transport._filter_algorithm..)Úgetattrr¹r²)rþrÚdefaultrhrriÚ_filter_algorithmsþzTransport._filter_algorithmcCs | d¡S)NÚciphers©r©rþrhrhriÚpreferred_ciphersszTransport.preferred_cipherscCs | d¡S)NZmacsrrrhrhriÚpreferred_macsszTransport.preferred_macscCs$| d¡}t|tdd„|DƒƒƒS)NÚkeyscss|]}d |¡VqdS)z{}-cert-v01@openssh.comN)r¹r rhrhrir(r¥z+Transport.preferred_keys..)rr²)rþÚfilteredrhrhriÚpreferred_keyss  ÿÿzTransport.preferred_keyscCs | d¡S)NZpubkeysrrrhrhriÚpreferred_pubkeys+szTransport.preferred_pubkeyscCs | d¡S)NÚkexrrrhrhriÚ preferred_kex/szTransport.preferred_kexcCs | d¡S)NÚ compressionrrrhrhriÚpreferred_compression3szTransport.preferred_compressioncCsœttt|ƒƒt@ƒ}d |¡}|js.|d7}nb|jdkrZ|d |j|j|jdd¡7}| ¡rx|d t |j ƒ¡7}n|j rˆ|d7}n|d 7}|d 7}|S) úP Returns a string representation of this object, for debugging. z) ÚhexrTÚidrr¹r«rÅÚ _cipher_infoÚis_authenticatedr¯rÞr×)rþZid_ÚoutrhrhriÚ__repr__7s$   þÿ zTransport.__repr__cCs|j ¡| ¡dS)a¦ 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)r£ÚcloserrhrhriÚatforkPs zTransport.atforkcCst|ƒS)a  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. )ÚSecurityOptionsrrhrhriÚget_security_options]szTransport.get_security_optionscCs6|sdS|dur|j}|r,|dur,t |¡}||_dS)aý 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)r¡r³ÚgetfqdnrÑ)rþrÑÚ trust_dnsÚgssapi_requestedrhrhriÚ set_gss_hostfs  zTransport.set_gss_hostcCsžd|_|dur ||_| ¡dSt ¡|_}| ¡|durJt ¡|nd}| d¡|jsz| ¡}|durr|‚tdƒ‚|  ¡sš|durNt ¡|krNqšqNdS)a| 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) TNr›úNegotiation failed.) r«ròÚstartrºrèÚtimeÚwaitÚ get_exceptionr]Úis_set)rþÚeventÚtimeoutZmax_timer rhrhriÚ start_clientˆs(# ÿ ÿzTransport.start_clientcCsŒ|durtƒ}d|_||_d|_|dur:||_| ¡dSt ¡|_}| ¡| d¡|js||  ¡}|durt|‚t dƒ‚|  ¡rPqˆqPdS)ap 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) NTr›r1) r[r÷rør«ròr2rºrèr4r5r]r6)rþr7Úserverr rhrhriÚ start_serverÂs&* zTransport.start_servercCs0||j| ¡<t|tƒr,||jd<||jd<dS)a 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`. rzryN)rùÚget_namer­rY)rþÚkeyrhrhriÚadd_server_keys   zTransport.add_server_keycCs&z|j|jWSty Yn0dS)aê 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ÎÚKeyErrorrrhrhriÚget_server_keys  zTransport.get_server_keyc Cs`tƒt_ddg}|dur$| d|¡|D],}ztj |¡WdStyRYq(0q(dt_dS)a— (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. z/etc/ssh/moduliz/usr/local/etc/moduliNrTF)rRrkÚ _modulus_packÚinsertÚ read_fileÚIOError)ÚfilenameÚ file_listÚfnrhrhriÚload_server_moduli-s   zTransport.load_server_modulicCs<|js dS| ¡t|j ¡ƒD] }| ¡q |j ¡dS)zP Close this session, and any open channels that are tied to it. N)r«rgÚlistrÞÚvaluesÚ_unlinkr£r))rþÚchanrhrhrir)Vs  zTransport.closecCs|jr |jstdƒ‚|jS)a´ 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 úNo existing session)r«r×r]rÏrrhrhriÚget_remote_server_keyas zTransport.get_remote_server_keycCs|jS)z´ Return true if this session is active (open). :return: True if the session is still active (open); False if the session is closed )r«rrhrhriÚ is_activerszTransport.is_activecCs|jd|||dS)a¥ 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. Úsession)Ú window_sizeÚmax_packet_sizer8©Ú open_channel)rþrQrRr8rhrhriÚ open_session|s üzTransport.open_sessioncCs|jd|dS)aÁ 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 Úx11)Úsrc_addrrS)rþrWrhrhriÚopen_x11_channelŸszTransport.open_x11_channelcCs | d¡S)aB 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 úauth-agent@openssh.comrSrrhrhriÚopen_forward_agent_channel¯s z$Transport.open_forward_agent_channelcCs| d||¡S)aC 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 úforwarded-tcpiprS)rþrWÚ dest_addrrhrhriÚopen_forwarded_tcpip_channel½s z&Transport.open_forwarded_tcpip_channelc Csü|jstdƒ‚|durdn|}|j ¡z| |¡}| |¡}| ¡}tƒ}| t ¡|  |¡|  |¡|  |¡|  |¡|dks|dkrÊ|  |d¡|  |d¡|  |d¡|  |d¡n$|dkrî|  |d¡|  |d¡t |ƒ} |j  || ¡t ¡|j|<} d |j|<|  |¡|  ||¡W|j ¡n |j ¡0| |¡t ¡} |  d ¡|js’| ¡} | durŽtd ƒ} | ‚|  ¡r¢qÀn| |t ¡krbtd ƒ‚qb|j  |¡} | durÚ| S| ¡} | durôtd ƒ} | ‚dS) as 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. úSSH session not activeNir[ú direct-tcpiprrrVTr›zUnable to open channel.zTimeout opening channel.)r«r]rÜÚacquireÚ_sanitize_window_sizeÚ_sanitize_packet_sizeÚ _next_channelrOÚadd_byterÚ add_stringÚadd_intrrÞÚputrºrèrßràÚ_set_transportÚ _set_windowÚreleaseÚ_send_user_messager3r4r5r6r ) rþÚkindr\rWrQrRr8ÚchanidÚmrLr7Ústart_tsr rhrhrirTÉs`,                  zTransport.open_channelcslˆjstdƒ‚t|ƒ}ˆjd||fdd}|dur:tdƒ‚|dkrJ| ¡}|durb‡fdd „}|}|ˆ_|S) a¾ 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 r^ú tcpip-forwardT©r4NzTCP forwarding request deniedrcsˆ |¡dSre©Ú_queue_incoming_channel)ÚchannelrWZdest_addr_portrrhriÚdefault_handlerUsz7Transport.request_port_forward..default_handler)r«r]r°Úglobal_requestÚget_intræ)rþÚaddressr¢ÚhandlerÚresponserurhrriÚrequest_port_forward(s! ÿ zTransport.request_port_forwardcCs(|js dSd|_|jd||fdddS)a. 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 Núcancel-tcpip-forwardTrq)r«rærv)rþrxr¢rhrhriÚcancel_port_forward^s zTransport.cancel_port_forwardcCs t |¡S)aE 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 )r\Zfrom_transportrrhrhriÚopen_sftp_clientls zTransport.open_sftp_clientcCsLtƒ}| t¡|dur.tt d¡ƒdd}| t |¡¡| |¡dS)a± 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. Nrr’é )rOrdrrUÚosÚurandomÚ add_bytesrk)rþZ byte_countrnrhrhriÚ send_ignorexs  zTransport.send_ignorecCsRt ¡|_| ¡|j d¡|js@| ¡}|dur8|‚tdƒ‚|j ¡rqNqdS)aK 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) r›Nr1) rºrèròÚ_send_kex_initr4r«r5r]r6©rþr rhrhriÚrenegotiate_keysŠs   zTransport.renegotiate_keyscCs$t |¡fdd„}|j ||¡dS)aÄ 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|jdddS)Nzkeepalive@lag.netFrq)rv)r rhrhriÚ_request°sz)Transport.set_keepalive.._requestN)ÚweakrefÚproxyrÀÚ set_keepalive)rþÚintervalr‡rhrhrirФs zTransport.set_keepalivecCs’|rt ¡|_tƒ}| t¡| |¡| |¡|durD|j|Ž|  t d  |¡¡|  |¡|shdS|j  d¡|js~dS|j ¡rhqŒqh|jS)aŒ 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. NzSending global request "{}"r›)rºrèròrOrdrreÚ add_booleanÚaddÚ_logrr¹rkr4r«r6rñ)rþrlÚdatar4rnrhrhrirvµs$        zTransport.global_requestcCsr|j ¡zVt|jƒdkr(|j d¡}n,|j |¡t|jƒdkrP|j d¡}nd}W|j ¡n |j ¡0|S)aW 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 rN)rÜr`r¯rúÚpoprür4rj)rþr8rLrhrhriÚacceptÚs  zTransport.acceptr¨c Cs€|dur*t|tƒrgd¢|_n | ¡g|_|j|| |p8|d| ¡|durä|sä| ¡} |  ¡| ¡ksz|  ¡| ¡krÎ| t d¡| t d  | ¡t | ¡ƒ¡¡| t d  |  ¡t |  ¡ƒ¡¡t dƒ‚| t d  | ¡¡¡|dusþ|dusþ|sþ|r||r"| t d¡|  ||j|¡nZ|r@| t d ¡| |¡n<|durd| t d ¡| ||¡n| t d ¡| ||¡dS) a 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. N)ryrzr{)rÑr.r/zBad host key from serverzExpected: {}: {}zGot : {}: {}zHost key verified ({})z,Attempting GSS-API auth... (gssapi-with-mic)z)Attempting GSS-API auth... (gssapi-keyex)zAttempting public-key auth...zAttempting password auth...)r­rYÚ_preferred_keysr<r0r9rNÚasbytesrŽrr¹Úreprr]Úauth_gssapi_with_micrÑÚauth_gssapi_keyexÚauth_publickeyÚ auth_password) rþZhostkeyÚusernameÚpasswordÚpkeyrÑZgss_authrÿrZ gss_trust_dnsr=rhrhrirŸósd<   ý ÿþ ÿþÿþÿÿÿ      zTransport.connectcCs8|j ¡z|j}d|_|W|j ¡S|j ¡0dS)ay 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Ür`rçrjr…rhrhrir5ss  þzTransport.get_exceptioncOs:z(|j ¡|||f|j|<W|j ¡n |j ¡0dS)a' 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 handler: subclass of `.SubsystemHandler` that handles this subsystem. N©rÜr`rýrj)rþÚnameryZlargÚkwargrhrhriÚset_subsystem_handler‡s zTransport.set_subsystem_handlercCs|jo|jduo|j ¡S)a 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)r«rðr&rrhrhrir&›s ÿýzTransport.is_authenticatedcCs|jr|jdurdS|j ¡S)a 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)r«rðÚ get_usernamerrhrhrir ªszTransport.get_usernamecCs|jr|jdurdS|jjS)zè 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)r«rðZbannerrrhrhriÚ get_banner¶s zTransport.get_bannercCs@|jr |jstdƒ‚t ¡}t|ƒ|_|j ||¡|j |¡S)aô 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 rM) r«r×r]rºrèr rðÚ auth_noneÚwait_for_response©rþr™Úmy_eventrhrhrir¢Ãs   zTransport.auth_nonec sÖ|jr |jstdƒ‚|dur&t ¡}n|}t|ƒ|_|j |ˆ|¡|durPgSz|j |¡WSt yÐ}zZ|r|d|j vr~‚z&‡fdd„}|  ||¡WWYd}~Styº|‚Yn0WYd}~n d}~00dS)a 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 rMNzkeyboard-interactivecs*t|ƒdkrtdƒ‚t|ƒdkr$gSˆgS)NrzFallback authentication failed.r)r¯r])ÚtitleÚ instructionsÚfields©ršrhriry$s   z(Transport.auth_password..handler) r«r×r]rºrèr rðr˜r£r^Z allowed_typesÚauth_interactive)rþr™ršr7Úfallbackr¥r ryrhr©rir˜ßs&/     zTransport.auth_passwordcCs\|jr |jstdƒ‚|dur&t ¡}n|}t|ƒ|_|j |||¡|durPgS|j |¡S)aˆ 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 rMN) r«r×r]rºrèr rðr—r£)rþr™r=r7r¥rhrhrir—4s#   zTransport.auth_publickeycCsD|jr |jstdƒ‚t ¡}t|ƒ|_|j ||||¡|j |¡S)aø 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 rM) r«r×r]rºrèr rðrªr£)rþr™ryÚ submethodsr¥rhrhrirªes+  ÿzTransport.auth_interactivecCs|s dd„}| |||¡S)a 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. cSsRg}|rt| ¡ƒ|r$t| ¡ƒ|D]$\}}t| ¡dd| tƒ¡q(|S)Nú )Úend)ÚprintÚstripÚappendrW)r¦r§Z prompt_listZanswersÚpromptZ show_inputrhrhriry¤s   z0Transport.auth_interactive_dumb..handler)rª)rþr™ryr¬rhrhriÚauth_interactive_dumbšs zTransport.auth_interactive_dumbcCsD|jr |jstdƒ‚t ¡}t|ƒ|_|j ||||¡|j |¡S)a¬ 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 rM) r«r×r]rºrèr rðr•r£)rþr™rÑrr¥rhrhrir•±s  ÿzTransport.auth_gssapi_with_miccCs@|jr |jstdƒ‚t ¡}t|ƒ|_|j ||¡|j |¡S)aZ 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 rM) r«r×r]rºrèr rðr–r£r¤rhrhrir–Ës   zTransport.auth_gssapi_keyexcCs$||_t |¡|_|j |j¡dS)ag 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þrrhrhriÚset_log_channelâs  zTransport.set_log_channelcCs|jS)z• Return the channel name used for this transport's logging. :return: channel name as a `str` .. versionadded:: 1.2 )rìrrhrhriÚget_log_channelñszTransport.get_log_channelcCs|j |¡dS)aa 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ÀÚ set_hexdump)rþÚhexdumprhrhrir·ûs zTransport.set_hexdumpcCs |j ¡S)z× 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ÀÚ get_hexdumprrhrhrir¹s zTransport.get_hexdumpcCs|r d|_nd|_dS)a£ 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 r˜rŠN)Ú_preferred_compression)rþÚcompressrhrhriÚuse_compressions zTransport.use_compressioncCs t|jddƒ}|durdS|ƒS)a 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. Ú getpeernameN)Úunknownr)rr£)rþÚgprhrhrir½#s zTransport.getpeernamecCsjd|_|j ¡tr6| ¡rf|t ¡urf| d¡qn0| ¡rf|t ¡urf|jj sf|jj sf| d¡q6dS)NFrr›) r«rÀr)rXÚis_aliverºÚcurrent_threadÚjoinr£Ú_closedÚclosedrrhrhrirg4s  ÿ þýüzTransport.stop_threadcGsBtt|ƒtƒr(|D]}|j ||¡qn|jj||g|¢RŽdSre)Ú issubclassr±rIrîÚlog)rþÚlevelÚmsgÚargsrnrhrhrirŽMszTransport._logcCs|jS)z0used by KexGex to find primes for group exchange)rArrhrhriÚ_get_modulus_packTszTransport._get_modulus_packcCsB|j}|j |¡dur.|jdd@|_|j}q|jdd@|_|S)zyou are holding the lockNriÿÿÿ)rárÞr ©rþrmrhrhrircXs zTransport._next_channelcCs|j |¡dS)z?used by a Channel to remove itself from the active channel listN)rÞÚdeleterËrhrhriÚ_unlink_channelaszTransport._unlink_channelcCs|j |¡dSre)rÀÚ send_message)rþrrhrhriÚ _send_messageeszTransport._send_messagecCst ¡}|j d¡|js*| td¡dS|j ¡|j ¡r@qf|j  ¡t ¡||j krt dƒ‚qz|  |¡W|j  ¡n |j  ¡0dS)z{ send a message, but block if we're in key negotiation. this is used for user-initiated requests. r›z0Dropping user packet because connection is dead.Nz2Key-exchange timed out waiting for key negotiation) r3rér4r«rŽrrêr`r6rjrër]rÏ)rþrr2rhrhrirkhs$ ÿ   ÿ zTransport._send_user_messagecCs ||_||_|jdur||_dS)zR Used by a kex obj to set the K (root key) and H (exchange hash). N)rÖrÕrÍ)rþÚkÚhrhrhriÚ_set_K_H‚s zTransport._set_K_HcGst|ƒ|_dS)zW Used by a kex obj to register the next packet type it expects to see. N)r²rÚ)rþZptypesrhrhriÚ_expect_packet‹szTransport._expect_packetcCsP|j|jt|ƒƒ}|dur$tdƒ‚| |jt|ƒ¡sFtd |j¡ƒ‚||_dS)NzUnknown host key typez#Signature verification ({}) failed.)Ú _key_inforÎrOr]Zverify_ssh_sigrÕr¹rÏ)rþrÏÚsigr=rhrhriÚ _verify_key‘sÿÿzTransport._verify_keyc Cstƒ}| |j¡| |j¡| t|ƒ¡| |j¡t|j ddƒ}d  |j j j |¡}|durlt }|d7}t|dƒsŽ| t|¡t|ddƒ|| ¡ƒ ¡}}t|ƒ|krøtƒ}| |j¡| |j¡| |¡|| ¡ƒ ¡}||7}||7}q¢|d|…S)z0id is 'A' - 'F' for the various keys used by sshÚ hash_algoNz&kex engine {} specified hash_algo {!r}z, falling back to sha1Z_logged_hash_selectionT)rOZ add_mpintrÖr‚rÕrdrVrÍrrÔr¹Ú __class__Ú__name__rÚhasattrrŽrÚsetattrr“Údigestr¯) rþr$Únbytesrnr×Zhash_select_msgr'ZsofarrÜrhrhriÚ _compute_keys2    ÿ        zTransport._compute_keycCsb||jvrtd|ƒ‚nFt|j|d|ƒ|j|d|ƒtƒd}||jurV| ¡S| ¡SdS)NzUnknown client cipher rrŽ)Úbackend)r%r]r rÚ_ENCRYPTZ encryptorZ decryptor)rþrr=ZivZ operationÚcipherrhrhriÚ _get_cipher»s ý zTransport._get_ciphercs&|dur‡fdd„}|ˆ_n|ˆ_dS)Ncsˆ |¡dSrerr)rtrrhriruÌsz=Transport._set_forward_agent_handler..default_handler)rä©rþryrurhrriÚ_set_forward_agent_handlerÉs z$Transport._set_forward_agent_handlercs&|dur‡fdd„}|ˆ_n|ˆ_dS)Ncsˆ |¡dSrerr)rtZ src_addr_portrrhriru×sz3Transport._set_x11_handler..default_handler)rårãrhrriÚ_set_x11_handlerÓs zTransport._set_x11_handlercCs@|j ¡z$|j |¡|j ¡W|j ¡n |j ¡0dSre)rÜr`rúr±rüÚnotifyrj)rþrtrhrhrirsÞs    z!Transport._queue_incoming_channelcCs|dur|j}tt|tƒSre)rãrdr4r6)rþrQrhrhriraæszTransport._sanitize_window_sizecCs|dur|j}tt|tƒSre)rârdr5r6)rþrRrhrhrirbëszTransport._sanitize_packet_sizecCs‚|jr|tks| ¡rdStƒ}|tkr4| t¡nJ|tkr~| ¡}|  ¡}| t ¡|  |¡|  t ¡|  d¡|  d¡|S)ao 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. Nr¨Úen)r÷r9r&rOr&rdr r+Úget_textrwr$rfr"re)rþÚptypeÚmessageZreplyrlrmrhrhriÚ_ensure_authedðs& ÿþý      zTransport._ensure_authedc Cs4t|_t |¡ttt|ƒƒt@ƒ}|jr>| t d  |¡¡n| t d  |¡¡zÀzŽ|j   t |jdƒ¡| t d  |j¡¡| ¡|j  |j¡| ¡| t¡|jrà|j  ¡rÊ|jsÊ| ¡z|j  ¡\}}WntyòYqªYn0|tkrqªn0|tkr| |¡qàn|tkr2| |¡qªt|j ƒdkrŒ||j vr`t!d  |j |¡ƒ‚t"ƒ|_ |dkrŒ|dkrŒ|j# $||¡qª||j%vrÊ| &||¡}|r¶| '|¡n|j%|||ƒn ||j(vr>| )¡}|j* +|¡}|dur|j(|||ƒn6||j,vr&| t d   |¡¡n| t-d   |¡¡qàn–|j.dur„||j.j%vr„|j.j%|}||j.|ƒt|j ƒdkrÔqªnPt/|}d   ||¡} | t0| ¡|t1krÔt2ƒ} |  3t4¡|  5|j6¡| '| ¡|j  7¡qªWnjt!yB} zD| t-d   |jr d nd| ¡¡| t-t8 9¡¡| |_:WYd} ~ nd} ~ 0t;yx} z| t d¡| |_:WYd} ~ nàd} ~ 0t| j?ƒt"urÐ| j?r¼d  | j?d| j?d¡} nt@| ƒpÌtA| ƒ} n| j?} | t-d| ¡| |_:WYd} ~ nXd} ~ 0tByN} z6| t-dt@| ƒ¡| t-t8 9¡¡| |_:WYd} ~ n d} ~ 00t C|¡tD|j* E¡ƒD]}| F¡qh|jrd|_|j  G¡|jHdur¦|jH I¡|j.dur¼|j. J¡|jK E¡D]} |  I¡qÆz"|jL M¡|jN O¡W|jL P¡n |jL P¡0|jQ G¡Wn|jjRdur*‚Yn0dS)Nz!starting thread (server mode): {}z!starting thread (client mode): {}z zLocal version/idstring: {}rz$Expecting packet from {!r}, got {:d}rªé)z&Ignoring message for dead channel {:d}z(Channel request for unknown channel {:d}zOops, unhandled type {} ({!r})zException ({}): {}r:ÚclientzEOF in transport threadz {} ({:d})rzSocket exception: zUnknown exception: F)SÚsysrfr±r#rTr$rr÷rŽrr¹rÀZ write_allrVrÃÚ _check_bannerZstart_handshakerôr„rÓrr«Ú need_rekeyrØZ read_messagerQrrÚ_parse_disconnectrÚ _parse_debugr¯rÚr]r²rÔZ parse_nextÚ_handler_tablerërÏÚ_channel_handler_tablerwrÞr ràrrðr;rr:rOrdrrfZseqnoZcomplete_handshaker Z tb_stringsrçÚEOFErrorr³r·r±rÉr¸r”Ú ExceptionÚremoverIrJrKr)ròÚsetÚabortrßrÜr`rürærjr£Úmodules)rþÚtidrérnÚ error_msgrmrLryrÚwarningrÈr Zemsgr7rhrhriÚruns  þ         ÿÿ       ÿþÿþÿ þ  ÿ     ÿþ           z Transport.runcCs<d |¡}||kr||7}n|d ||¡7}| t|¡dS)Nz{}: zlocal={}, remote={})r¹rŽr)rþÚwhichÚlocalÚremoterÈrhrhriÚ_log_agreement»s   zTransport._log_agreementcCsZ|j ¡z|j ¡W|j ¡n |j ¡0|jdurB| ¡| |¡|j  ¡dSre) rêr`réÚclearrjrÇr„Ú_parse_kex_initrÔZ start_kex©rþrnrhrhriÚ_negotiate_keysÈs    zTransport._negotiate_keysc CshtdƒD]”}|dkr|j}nd}z|j |¡}WnFtyD‚Yn4tyv}ztdt|ƒƒ‚WYd}~n d}~00|dd…dkrŒqž| t d|¡q|dd…dkr¾td|d ƒ‚||_ | t d   |¡¡|  d ¡}|dkrô|d|…}|  d d¡}t|ƒd krtdƒ‚|d}|d}|dkrL|dkrLd}t|  |¡ƒ‚d  ||¡}| t|¡dS)Nédréz!Error reading SSH protocol bannerér¦zBanner: z!Indecipherable protocol version "ú"zRemote version/idstring: {}r­r§ézInvalid SSH bannerrz1.99rlz(Incompatible version ({} instead of 2.0)z!Connected (version {}, client {}))ÚrangerórÀÚreadlinerarör]r¸rŽrrÄr¹Úfindr®r¯r`r) rþÚir8Úbufr ZsegsÚversionrírÈrhrhrirïÕs@   ÿ    zTransport._check_bannercsŽ|j ¡z|j ¡W|j ¡n |j ¡0d|_d|_t|jƒ}|j r¸d‰‡fdd„|Dƒ}|j duršt |ƒdkrš‡fdd„|  ¡j Dƒ}||  ¡_ ttt|j ¡ƒj|jƒƒ}n|j}| d ¡tƒ}| t¡| t d ¡¡| |¡| |¡| |j¡| |j¡| |j¡| |j¡| |j¡| |j¡| tƒ¡| tƒ¡|  d¡| !d¡| "¡|_#|_$| %|¡dS) zƒ announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support. FTz!diffie-hellman-group-exchange-shacsg|]}| ˆ¡r|‘qSrh©Ú startswith©r rЩZmp_required_prefixrhriÚ  r¥z,Transport._send_kex_init..Nrcsg|]}| ˆ¡s|‘qSrhrrrrhrir s þú ext-info-crŒ)&rêr`rérrjrÐrØrIrr÷rAr¯r,rÚfilterrùrÚ __contains__rr±rOrdrr‚r€rZadd_listrrr reÚbytesrŒrfr“rÇÚ_latest_kex_initrÏ)rþZ kex_algosZkex_mpZpkexÚavailable_server_keysrnrhrrir„ sP    þ  öÿ              zTransport._send_kex_initcCsªi}|r| ¡| d¡| ¡|d<| ¡|d<| ¡|d<| ¡|d<| ¡|d<| ¡|d<| ¡|d<| ¡|d <| ¡|d <| ¡|d <| ¡|d <| ¡|S) NrŒÚ kex_algo_listÚserver_key_algo_listÚclient_encrypt_algo_listÚserver_encrypt_algo_listÚclient_mac_algo_listÚserver_mac_algo_listÚclient_compress_algo_listÚserver_compress_algo_listÚclient_lang_listÚserver_lang_listÚ kex_follows)Zget_byteÚ get_bytesZget_listÚ get_booleanrw)rþrnÚignore_first_byteÚparsedrhrhriÚ_really_parse_kex_initB s"            z Transport._really_parse_kex_initcCs|jt|jƒddS)NT)r*)r,rOrrrhrhriÚ_get_latest_kex_initU s ÿzTransport._get_latest_kex_initc Cs>| |¡}|d}|d}|d}|d}|d}|d}|d} |d} |d } |d } |d } | td ¡d |fd|fd|fd|fd|fd|fd| fd| fd| fd| ff D]6\}}|dgkrÆdg}d |¡}| td ||¡¡q®| td | ¡¡| td¡d|_|d d¡r$| ¡|_|jr@t t |j j |ƒƒ}nt t |j |j ƒƒ}t |ƒdkrhtd ƒ‚|j|d|ƒ|_| td! |d¡¡|jrÈt t t |j ¡ƒj |jƒƒ}t t |j |ƒƒ}nt t |j |jƒƒ}t |ƒdkrðtd"ƒ‚|d|_|jr| ¡durtd#ƒ‚| d$|d|d¡|jr\t t |jj |ƒƒ}t t |jj |ƒƒ}n$t t |j |jƒƒ}t t |j |jƒƒ}t |ƒdksœt |ƒdkr¤td%ƒ‚|d|_|d|_|jd&|j|jd'|jrút t |jj |ƒƒ}t t |jj |ƒƒ}n$t t |j |jƒƒ}t t |j |jƒƒ}t |ƒdks:t |ƒdkrBtd(ƒ‚|d|_|d|_|jd)|j|jd'|jr˜t t |jj | ƒƒ}t t |jj | ƒƒ}n$t t | j |jƒƒ}t t | j |jƒƒ}t |ƒdksØt |ƒdkrød*}|d+7}t| |||j¡ƒ‚|d|_|d|_|jd,|j|jd'| td-¡t | !¡|_"dS).Nrrrr r!r"r#r$r%r&r'z"=== Key exchange possibilities ===z kex algosz server keyzclient encryptzserver encryptz client macz server maczclient compresszserver compressz client langz server langr¨zz, z{}: {}zkex follows: {}z=== Key exchange agreements ===éÿÿÿÿz ext-info-rz3Incompatible ssh peer (no acceptable kex algorithm)zKex: {}z.Incompatible ssh peer (no acceptable host key)z;Incompatible ssh peer (can't match requested host key type)ZHostKeyz/Incompatible ssh server (no acceptable ciphers)r )rrz,Incompatible ssh server (no acceptable macs)ZMACz3Incompatible ssh server (no acceptable compression)z {!r} {!r} {!r}Z Compressionz=== End of kex handshake ===)#r,rŽrrÂr¹Ú_remote_ext_inforrr÷rIrrrr¯r`Ú _kex_inforÔrùrrrÎr@rrrÅrÆrrÉrÊr rËrÌrZ get_so_farrÈ)rþrnr+rrrr r!r"r#r$r%r&r'ÚprefixÚvalueZ agreed_kexrZ agreed_keysZagreed_local_ciphersZagreed_remote_ciphersZagreed_remote_macsZagreed_local_macsZagreed_remote_compressionZagreed_local_compressionrÈrhrhrirZ s\  ô      ÿ ÿÿþÿÿÿ ÿÿ ÿþÿþÿþÿþÿÿ   ÿ ÿ ÿ ÿ ÿÿ   ÿþÿþÿþÿþÿ ÿ þýÿ  ý zTransport._parse_kex_initc Cs*|j|jd}|jr<| d|¡}| d|j|jd¡}n$| d|¡}| d|j|jd¡}| |j|||j¡}d|jv}|j|jd}|j|jd }|jr¶| d |ƒj¡}n| d |ƒj¡}|j j ||||||d |j |j d } | dur&|j dks |j r&| td¡|j  | ƒ¡dS)zMswitch on newly negotiated encryption parameters for inbound trafficrÚAÚCrÚBÚDúetm@openssh.comr•rÚEÚF©ÚetmrNr™ú$Switching on inbound compression ...)r%rÆr÷rÞrâÚ_DECRYPTrÊÚ _mac_infoÚ digest_sizerÀZset_inbound_cipherÚ_compression_inforÌrÙrŽrÚset_inbound_compressor) rþÚ block_sizeZIV_inZkey_inÚenginer;Úmac_sizeÚ mac_engineÚmac_keyÚ compress_inrhrhriÚ_activate_inbound' s< ÿ ÿ ÿ  ÿ ÿÿ zTransport._activate_inboundc Csîtƒ}| t¡| |¡|j|jd}|jrV| d|¡}| d|j|jd¡}n$| d|¡}| d|j|jd¡}| |j|||j ¡}d|j v}|j |j d}|j |j d }|jrÐ| d |ƒj ¡} n| d |ƒj ¡} |j  d ¡} |jj||||| | |d |j|jd} | durN|jdks4|jrN| td¡|j | ƒ¡|j ¡s`d|_|jrà|jrà|jdkràdd |j¡i} tƒ}| t¡| t| ƒ¡t|   ¡ƒD]\} }| !| ¡| !|¡q¶| |¡| "t#¡dS)zNswitch on newly negotiated encryption parameters for outbound trafficrr5r6rr3r4r7r•rr9r8z-ctrr:rNr™ú%Switching on outbound compression ...Frzserver-sig-algsú,)$rOrdrrÏr%rÅr÷rÞrâràrÉr>r?ÚendswithrÀZset_outbound_cipherr@rËrÙrŽrÚset_outbound_compressorrðrØrör/rÂrr=rfr¯ÚsortedÚitemsrerÓr)rþrnrBZIV_outZkey_outrCr;rDrErFZsdctrÚ compress_outÚ extensionsrr2rhrhriÚ_activate_outboundK sf   ÿ ÿ ÿ  ÿ ÿÿ  ÿþý   zTransport._activate_outboundcCsrd|_|jdkr:|j|jd}| td¡|j |ƒ¡|jdkrn|j|jd}| td¡|j |ƒ¡dS)NTr™rrIrr<) rÙrËr@rŽrrÀrLrÌrA)rþrOrGrhrhriÚ _auth_trigger… s    zTransport._auth_triggercCsJi}t| ¡ƒD]}| ¡}| ¡}|||<q| td |¡¡||_dS)NzGot EXT_INFO: {})r rwrèÚ get_stringrŽrr¹r¬)rþrÈrPÚ_rr2rhrhriÚ_parse_ext_info‘ s zTransport._parse_ext_infocCsª| td¡| ¡d|_|_d|_d|_|jrF|jdurFt |ƒ|_|j sRd|_ |j durf|j   ¡|j  ¡svd|_|j ¡z|j  ¡W|j ¡n |j ¡0dS)NzSwitch to new keys ...TF)rŽrrHrÇrÈrÖrÔr÷rðr r×ròrørÀrðrØrêr`rérjrrhrhriÚ_parse_newkeysŸ s$        zTransport._parse_newkeyscCs(| ¡}| ¡}| td ||¡¡dS)NzDisconnect (code {:d}): {})rwrèrŽrr¹)rþrnÚcodeÚdescrhrhrirñ¹ szTransport._parse_disconnectc Cs| ¡}| td |¡¡| ¡}|js@| td |¡¡d}nl|dkrr| ¡}| ¡}|j ||¡}|r¬|f}n:|dkrž| ¡}| ¡}|j  ||¡d}n|j  ||¡}d}t |ƒt urÄ|}d}|rüt ƒ}|rè| t¡|j|Žn | t¡| |¡dS)NzReceived global request "{}"z*Rejecting "{}" global request from server.Frpr|Trh)rèrŽrr¹r)r÷rwrøZcheck_port_forward_requestZcancel_port_forward_requestZcheck_global_requestr±r²rOrdrrr rÏ) rþrnrlZ want_replyÚokrxr¢ÚextrarÈrhrhriÚ_parse_global_request¾ s@þ    zTransport._parse_global_requestcCs*| td¡||_|jdur&|j ¡dS)NzGlobal request successful.©rŽrrñròrørrhrhriÚ_parse_request_successâ s  z Transport._parse_request_successcCs*| td¡d|_|jdur&|j ¡dS)NzGlobal request denied.r\rrhrhriÚ_parse_request_failureè s  z Transport._parse_request_failurecCs®| ¡}| ¡}| ¡}| ¡}|j |¡}|durD| td¡dS|j ¡zN| |||¡| td  |¡¡||j vr|j |  ¡|j |=W|j  ¡n |j  ¡0dS)Nz%Success for unrequested channel! [??]zSecsh channel {:d} opened.) rwrÞr rŽrrÜr`Ú_set_remote_channelrr¹rßrørj)rþrnrmZ server_chanidZserver_window_sizeZserver_max_packet_sizerLrhrhriÚ_parse_channel_open_successî s&   ÿ  z%Transport._parse_channel_open_successcCs®| ¡}| ¡}| ¡}| ¡t |d¡}| td |||¡¡|j ¡zPt ||ƒ|_ ||j vr|j   |¡||j vr|j | ¡|j |=W|j ¡n |j ¡0dS)Nz(unknown code)z&Secsh channel {:d} open FAILED: {}: {})rwrèr!r rŽrr¹rÜr`r_rçrßrÞrÌrørj)rþrnrmrZ reason_strZ reason_textrhrhriÚ_parse_channel_open_failure s* ÿþ      z%Transport._parse_channel_open_failurecCsš| ¡}| ¡}| ¡}| ¡}d}|dkrt|jdurt| td¡|j ¡z| ¡}W|j ¡n |j ¡0n¦|dkrÜ|j durÜ| ¡}| ¡} | td  || ¡¡|j ¡z| ¡}W|j ¡n |j ¡0n>|dkrV|j durV| ¡} | ¡} | ¡}| ¡} | td  || ¡¡|j ¡z| ¡}W|j ¡n |j ¡0nÄ|j sz| td  |¡¡d }t } n |j ¡z| ¡}W|j ¡n |j ¡0|d krì| ¡} | ¡}| ¡}| ¡} |j ||| f| |f¡} n|j ||¡} | tkr| td   |¡¡d }|rftƒ}| t¡| |¡| | ¡| d ¡| d ¡| |¡dSt|ƒ}|j ¡zN|j ||¡d |j|<| |¡| |j|j¡|  |||¡W|j ¡n |j ¡0tƒ}| t!¡| |¡| |¡| |j¡| |j¡| |¡| td  ||¡¡|dkrD| |¡nR|dkr`|  ||| f¡n6|dkrŒ|| f|_"|  ||| f| | f¡n | #|¡dS)NFrYz!Incoming forward agent connectionrVz$Incoming x11 connection from {}:{:d}r[z.Incoming tcp forwarded connection from {}:{:d}z+Rejecting "{}" channel request from server.Tr_z+Rejecting "{}" channel request from client.r¨rçzSecsh channel {:d} ({}) opened.)$rèrwrärŽrrÜr`rcrjrår¹rær÷r"røZ"check_channel_direct_tcpip_requestZcheck_channel_requestr#rOrdr$rfrerÏrrÞrgràrhrirãrâr_r%Ú origin_addrrs)rþrnrlrmZinitial_window_sizerRZrejectZ my_chanidrbÚ origin_portZ server_addrZ server_portrr\Z dest_portrÈrLrhrhriÚ_parse_channel_open säÿþ   ÿþ  ÿþ  þ   ýÿ þ         ÿÿ       ÿ     ÿzTransport._parse_channel_opencCs4| ¡| ¡}| ¡| td t |¡¡¡dS)Nz Debug msg: {})r)rSrŽrr¹r Z safe_string)rþrnrÈrhrhriròš szTransport._parse_debugcCsRz@|j ¡||jvr,dgifW|j ¡S|j|W|j ¡S|j ¡0dSrerœr´rhrhriÚ_get_subsystem_handler  s    ý  þz Transport._get_subsystem_handler)TT)NN)NN)N)NNN)N)NNNNN)N)N)NT)N) Nr¨NNNFFTT)NT)N)r¨)Nr¨)T)F)´rÙÚ __module__Ú __qualname__Ú__doc__Úobjectràr=rÁr¹ÚparamikoÚ __version__rÂÚ_preferred_ciphersÚ_preferred_macsr’Z_preferred_pubkeysrÓrBZ is_availablerÒrºrZAESr ZCTRZCBCZ TripleDESr%rrrrr>rYr@rZrArÔrErFrCrDrGrHrMrNrLrIrJrKr0r>r?r@rAr¿r7r8r¼rÚpropertyrrrrrr r(r*r,r0r9r;r>r@Ú staticmethodrHr)rNrOrUrXrZr]rTr{r}r~rƒr†rŠrvr‘rŸr5rŸr&r r¡r¢r˜r—rªr³r•r–rµr¶r·r¹r¼r½rgrŽrÊrcrÍrÏrkrÒrÓrÖrÞrârärårsrarbrërþrrrïr„r,r-rrHrQrRrUrVrñr[r]r^r`rardròrer<rr&r'r(r)r*r+rrór,rZ_request_successr-Z_request_failedr.Z_feedr/Z_feed_extendedr0Z_window_adjustr1Z_handle_requestr2Z _handle_eofr3Z _handle_closerôrhrhrhrirk„sà       üüüüüüüÛ.øìô ú ø M        " : B (  ÿ # ù _ 6  % ö    U 1 5         &&  +B N$: $~ ÷ ørkc@s®eZdZdZdZdd„Zdd„Zdd„Zed d „ƒZ e j d d „ƒZ ed d „ƒZ e j dd „ƒZ edd„ƒZ e j dd„ƒZ edd„ƒZ e j dd„ƒZ edd„ƒZej dd„ƒZdS)r+a: 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. Ú _transportcCs ||_dSre)rp)rþÚ transportrhrhrir¼Ó szSecurityOptions.__init__cCs d |j¡S)r!z#)r¹rprrhrhrir(Ö szSecurityOptions.__repr__cstt|ƒturt|ƒ}t|ƒtur(tdƒ‚tt|j|ƒ ¡ƒ‰‡fdd„|Dƒ}t|ƒdkrbtdƒ‚t |j||ƒdS)Nzexpected tuple or listcsg|]}|ˆvr|‘qSrhrh)r Ún©Úpossiblerhrirâ r¥z(SecurityOptions._set..rzunknown cipher) r±rIr²Ú TypeErrorrrprr¯Ú ValueErrorrÛ)rþrÚorigr Ú forbiddenrhrsriÚ_setÜ s   zSecurityOptions._setcCs|jjS)zSymmetric encryption ciphers)rprlrrhrhrirç szSecurityOptions.cipherscCs| dd|¡dS)Nrlr%©ry©rþr rhrhrirì scCs|jjS)z Digest (one-way hash) algorithms)rprmrrhrhriÚdigestsð szSecurityOptions.digestscCs| dd|¡dS)Nrmr>rzr{rhrhrir|õ scCs|jjS)zPublic-key algorithms)rpr’rrhrhriÚ key_typesù szSecurityOptions.key_typescCs| dd|¡dS)Nr’rÔrzr{rhrhrir}þ scCs|jjS)zKey exchange algorithms)rprÓrrhrhrir szSecurityOptions.kexcCs| dd|¡dS)NrÓr0rzr{rhrhrir scCs|jjS)zCompression algorithms)rprºrrhrhrir szSecurityOptions.compressioncCs| dd|¡dS)Nrºr@rzr{rhrhrir sN)rÙrfrgrhÚ __slots__r¼r(ryrnrÚsetterr|r}rrrhrhrhrir+Ä s2           r+c@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)rÝcCst ¡|_t ¡|_dSre)rˆÚWeakValueDictionaryÚ_maprºrÛÚ_lockrrhrhrir¼ s zChannelMap.__init__cCs4|j ¡z||j|<W|j ¡n |j ¡0dSre)r‚r`rrj)rþrmrLrhrhrirg s  zChannelMap.putcCs6|j ¡z|j |d¡W|j ¡S|j ¡0dSre)r‚r`rr rjrËrhrhrir " s   þzChannelMap.getcCsJ|j ¡z.z |j|=Wnty*Yn0W|j ¡n |j ¡0dSre)r‚r`rr?rjrËrhrhrirÌ) s   zChannelMap.deletecCs6|j ¡zt|j ¡ƒW|j ¡S|j ¡0dSre)r‚r`rIrrJrjrrhrhrirJ3 s   þzChannelMap.valuescCs2|j ¡zt|jƒW|j ¡S|j ¡0dSre)r‚r`r¯rrjrrhrhriÚ__len__: s    þzChannelMap.__len__N) rÙrfrgr¼rgr rÌrJrƒrhrhrhrirÝ s  rÝ)rhÚ __future__rr€r³rîrºr3rˆÚhashlibrrrrZcryptography.hazmat.backendsrZ&cryptography.hazmat.primitives.ciphersrr r rjr Zparamiko.auth_handlerr Zparamiko.ssh_gssr Zparamiko.channelrZparamiko.commonrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=Zparamiko.compressr>r?Zparamiko.dsskeyr@Zparamiko.ed25519keyrAZparamiko.kex_curve25519rBZparamiko.kex_gexrCrDZparamiko.kex_group1rEZparamiko.kex_group14rFrGZparamiko.kex_group16rHZparamiko.kex_ecdh_nistrIrJrKZparamiko.kex_gssrLrMrNZparamiko.messagerOZparamiko.packetrPrQZparamiko.primesrRZparamiko.py3compatrSrTrUrVrWrXZparamiko.rsakeyrYZparamiko.ecdsakeyrZZparamiko.serverr[Zparamiko.sftp_clientr\Zparamiko.ssh_exceptionr]r^r_r`raZ paramiko.utilrbrcrdrfrjÚatexitÚregisterr»rkrir+rÝrhrhrhriÚs‚      Ä1             VQ