U vù¾fs ã@s.dZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z ddl m Z ddlmZmZmZddlZddlmZddlmZmZddlmZdd lmZdd lmZmZmZmZm 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@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMdd lNmOZOmPZPdd lQmRZRdd lSmTZTddlUmVZVddlWmXZXmYZYddlZm[Z[ddl\m]Z]m^Z^ddl_m`Z`ddlambZbmcZcmdZdddlemfZfmgZgmhZhddlimjZjddlkmlZlmmZmddlnmoZoddlpmqZqddlrmsZsddltmuZuddlvmwZwddlxmyZymzZzm{Z{m|Z|m}Z}m~Z~ddlm€Z€mZm‚Z‚zddlƒm„Z„Wn"e…k rÊddl†m„Z„YnXgZ‡dd „Zˆddl‰Z‰e‰ Šeˆ¡Gd!d"„d"ej‹e€ƒZŒGd#d$„d$ƒZGd%d&„d&ƒZŽGd'd(„d(eŒƒZdS))z Core protocol implementation éN)Úmd5Úsha1Úsha256Úsha512)Údefault_backend)Ú algorithmsÚCipherÚmodes)Úutil)Ú AuthHandlerÚAuthOnlyHandler)ÚGSSAuth)ÚChannel)2Ú 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ÚcMSG_SERVICE_REQUESTÚMSG_SERVICE_ACCEPTÚ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Úbyte_ord)ÚZlibCompressorÚZlibDecompressor)ÚDSSKey)Ú Ed25519Key)Ú KexCurve25519)ÚKexGexÚ KexGexSHA256)Ú KexGroup1)Ú KexGroup14ÚKexGroup14SHA256)ÚKexGroup16SHA512)Ú KexNistp256Ú KexNistp384Ú KexNistp521)Ú KexGSSGexÚ KexGSSGroup1Ú KexGSSGroup14)ÚMessage)Ú PacketizerÚNeedRekeyException)Ú ModulusPack)ÚRSAKey)ÚECDSAKey)ÚServerInterface)Ú SFTPClient)ÚBadAuthenticationTypeÚChannelExceptionÚIncompatiblePeerÚMessageOrderErrorÚProxyCommandFailureÚ SSHException)ÚClosingContextManagerÚ clamp_valueÚb)Ú TripleDEScCstD] }| ¡qdS©N)Ú_active_threadsÚ stop_thread)Zthr©rgúC/opt/alt/python38/lib/python3.8/site-packages/paramiko/transport.pyÚ_join_lingering_threadsŽsric@sòeZdZdZeƒ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 œeejdd 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 ¡rdee2d<e3e4fe3e4fddœZ5dZ6dZ7e8e9ddddddfdd„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¶„Z‡dê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—d×dØ„Z˜e™ešj›eœešjež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é é@)rprrrlrnrmrorqrs)rzzssh-rsa-cert-v01@openssh.comryz!rsa-sha2-256-cert-v01@openssh.comrxz!rsa-sha2-512-cert-v01@openssh.comr{zssh-dss-cert-v01@openssh.comruz(ecdsa-sha2-nistp256-cert-v01@openssh.comrvz(ecdsa-sha2-nistp384-cert-v01@openssh.comrwz(ecdsa-sha2-nistp521-cert-v01@openssh.comrtz ssh-ed25519-cert-v01@openssh.com) r„rƒr‚r€rrrˆr‡r†r|r}r~r…)NN©úzlib@openssh.comÚzlibrŠNçš™™™™™¹?FTc CsNd|_d|_i|_||_d|_t|tƒrl| dd¡} | d|_t| ƒdkrX| ddf}n| dt | dƒf}t |ƒt kr(|\} } | |_d} t   | | t jt j¡}|D]r\}}}}}|t jkr¤|}t   |t j¡}z| | | f¡Wn.t jk r}z t|ƒ} W5d}~XYq¤Xq(q¤td | | ¡ƒ‚tj |¡d |_||_|j |j¡| pVt|ƒ|_d |jd |j|_d |_ d |_!|_"d|_#|_$d|_%|_&d|_'|_(d|_)d|_*d|_+||_,d|_-d|_.d|_/|j,röt0d |ƒ|_.|j1|j2|_2d|_3d|_4d|_5d|_6d|_7d|_8t ƒ|_9t :¡|_;t<ƒ|_=i|_>i|_?d|_@||_A||_Bd|_Cd|_Dd|_Ed|_Ft G¡|_Ht :¡|_Id|_Jd|_KtL M|jK¡|_N|j O|jN¡d|_Pd|_Qd|_Rd|_Sd|_Td|_Ud|_V|pØi|_W||_Xd|_Yd|_Zi|_[g|_\t ]|j;¡|_^i|__t`|jatb|jctd|jetf|jgth|jitj|jktl|jmtn|jotp|jqi |_rdS)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(bytes)``: Writes from 1 to ``len(bytes)`` 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``. :param bool strict_kex: Whether to advertise (and implement, if client also advertises support for) a "strict kex" mode for safer handshaking. Default: ``True``. :param packetizer_class: Which class to use for instantiating the internal packet handler. Default: ``None`` (i.e.: use `Packetizer` as normal). .. 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. .. versionchanged:: 3.4 Added the ``strict_kex`` kwarg. .. versionchanged:: 3.4 Added the ``packetizer_class`` kwarg. FNú:érézNo suitable address familyzUnable to connect to {}: {}TúSSH-ú-Úz gssapi-keyexg>@zparamiko.transportééi)sÚactiveÚhostnameÚserver_extensionsÚadvertise_strict_kexÚagreed_on_strict_kexÚ isinstanceÚstrÚsplitÚlenÚintÚtypeÚtupleÚsocketÚ getaddrinfoÚ AF_UNSPECÚ SOCK_STREAMÚconnectÚerrorr_ÚformatÚ threadingÚThreadÚ__init__ÚdaemonÚsockÚ settimeoutÚ_active_check_timeoutrSÚ 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Úchannel_timeoutÚdisabled_algorithmsÚserver_sig_algsÚ server_modeÚ server_objectÚserver_key_dictÚserver_acceptsÚ ConditionÚserver_accept_cvÚsubsystem_tabler>Ú_parse_ext_inforÚ_parse_newkeysr&Ú_parse_global_requestr'Ú_parse_request_successr(Ú_parse_request_failurer+Ú_parse_channel_open_successr,Ú_parse_channel_open_failurer-Ú_parse_channel_openrÚ_negotiate_keysÚ_handler_table)ÚselfrºràrßÚgss_kexÚgss_deleg_credsrórôZ strict_kexZpacketizer_classZhlr¤ÚportÚreasonÚ addrinfosÚfamilyÚsocktypeÚprotoÚ canonnameÚsockaddrÚafÚergrgrhr¸Wsàc    ÿ  ÿ          ÷zTransport.__init__cs(tˆd ˆ¡ƒ}t‡‡fdd„|DƒƒS)Nz _preferred_{}c3s$|]}|ˆj ˆg¡kr|VqdSrd)róÚget©Ú.0Úx©rÚtype_rgrhÚ Fsþz.Transport._filter_algorithm..)Úgetattrrµr®)rrÚdefaultrgrrhÚ_filter_algorithmDsþzTransport._filter_algorithmcCs | d¡S)NÚciphers©r©rrgrgrhÚpreferred_ciphersLszTransport.preferred_cipherscCs | d¡S)NZmacsrrrgrgrhÚpreferred_macsPszTransport.preferred_macscCs$| d¡}t|tdd„|DƒƒƒS)NÚkeyscss|]}d |¡VqdS)z{}-cert-v01@openssh.comN)rµrrgrgrhr]sz+Transport.preferred_keys..)rr®)rÚfilteredrgrgrhÚpreferred_keysTs  ÿÿzTransport.preferred_keyscCs | d¡S)NZpubkeysrrrgrgrhÚpreferred_pubkeys`szTransport.preferred_pubkeyscCs | d¡S)NÚkexrrrgrgrhÚ preferred_kexdszTransport.preferred_kexcCs | d¡S)NÚ compressionrrrgrgrhÚpreferred_compressionhszTransport.preferred_compressioncCs˜tt|ƒt@ƒ}d |¡}|js*|d7}nb|jdkrV|d |j|j|jdd¡7}| ¡rt|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) ÚhexÚidrrµr£rÂÚ _cipher_infoÚis_authenticatedr«rÛrÔ)rZid_ÚoutrgrgrhÚ__repr__ls$   þÿ 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ºÚcloserrgrgrhÚatfork…s 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. )ÚSecurityOptionsrrgrgrhÚget_security_options’szTransport.get_security_optionscCs6|sdS|dkr|j}|r,|dk r,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Î)rrÎÚ trust_dnsÚgssapi_requestedrgrgrhÚ set_gss_host›s  zTransport.set_gss_hostcCsžd|_|dk r ||_| ¡dSt ¡|_}| ¡|dk rJt ¡|nd}| d¡|jsz| ¡}|dk rr|‚tdƒ‚|  ¡sš|dk rNt ¡|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_timerrgrgrhÚ start_client½s(# ÿ ÿzTransport.start_clientcCsŒ|dkrtƒ}d|_||_d|_|dk r:||_| ¡dSt ¡|_}| ¡| d¡|js||  ¡}|dk rt|‚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šr:) rXrõrör£rïr;r¶rår=r>r_r?)rr@ÚserverrrgrgrhÚ 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`. ryrxN)r÷Úget_namer¨rV)rÚkeyrgrgrhÚadd_server_key9s   zTransport.add_server_keycCs(z|j|jWStk r"YnXdS)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ËÚKeyErrorrrgrgrhÚget_server_keyMs zTransport.get_server_keyc Csbtƒt_ddg}|dk r$| d|¡|D].}ztj |¡WdStk rTYq(Xq(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)rUrjÚ _modulus_packÚinsertÚ read_fileÚIOError)ÚfilenameÚ file_listÚfnrgrgrhÚload_server_modulibs  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£rfÚlistrÛÚvaluesÚ_unlinkrºr2)rÚchanrgrgrhr2‹s  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ÌrrgrgrhÚget_remote_server_key–s 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£rrgrgrhÚ is_active§szTransport.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_sizerA©Ú open_channel)rrZr[rArgrgrhÚ 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_addrr\)rr`rgrgrhÚ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.comr\rrgrgrhÚ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-tcpipr\)rr`Ú dest_addrrgrgrhÚopen_forwarded_tcpip_channelòs z&Transport.open_forwarded_tcpip_channelc Csô|jstdƒ‚|dkr|jn|}|j ¡z| |¡}| |¡}| ¡}t ƒ}|  t ¡|  |¡|  |¡|  |¡|  |¡|dks’|dkrÌ|  |d¡|  |d¡|  |d¡|  |d¡n$|dkrð|  |d¡|  |d¡t|ƒ} |j || ¡t ¡|j|<} d|j|<|  |¡|  ||¡W5|j ¡X| |¡t ¡} |  d ¡|jsŠ| ¡} | dkr†td ƒ} | ‚|  ¡ršq¸n| |t ¡krZtd ƒ‚qZ|j |¡} | dk rÒ| S| ¡} | dkrìtd ƒ} | ‚dS) ar 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 opening a channel .. versionchanged:: 1.15 Added the ``window_size`` and ``max_packet_size`` arguments. úSSH session not activeNrdú direct-tcpiprrœr_TršzUnable to open channel.zTimeout opening channel.)r£r_ròrÙÚacquireÚreleaseÚ_sanitize_window_sizeÚ_sanitize_packet_sizeÚ _next_channelrRÚadd_byterÚ add_stringÚadd_intrrÛÚputr¶rårÜrÝÚ_set_transportÚ _set_windowÚ_send_user_messager<r=r>r?r) rÚkindrer`rZr[rAÚchanidÚmrUr@Zstart_tsrrgrgrhr]þs`,                   zTransport.open_channelcslˆjstdƒ‚t|ƒ}ˆjd||fdd}|dkr:tdƒ‚|dkrJ| ¡}|dkrb‡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 rgú tcpip-forwardT©r=NzTCP forwarding request deniedrcsˆ |¡dSrd©Ú_queue_incoming_channel)Úchannelr`Zdest_addr_portrrgrhÚdefault_handlerŠsz7Transport.request_port_forward..default_handler)r£r_r¬Úglobal_requestÚget_intrã)rÚaddressr ÚhandlerÚresponser}rgrrhÚ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-forwardTry)r£rãr~)rr€r rgrgrhÚ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 )rYZfrom_transportrrgrgrhÚopen_sftp_client¡s zTransport.open_sftp_clientcCsLtƒ}| t¡|dkr.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. Nrœr‘é )rRrnrr@ÚosÚurandomÚ add_bytesrt)rZ byte_countrwrgrgrhÚ send_ignore­s  zTransport.send_ignorecCsRt ¡|_| ¡|j d¡|js@| ¡}|dk r8|‚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šNr:) r¶rårïÚ_send_kex_initr=r£r>r_r?©rrrgrgrhÚ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.netFry)r~)rrgrgrhÚ_requeståsz)Transport.set_keepalive.._requestN)ÚweakrefÚproxyr½Ú set_keepalive)rÚintervalrrgrgrhr’Ùs zTransport.set_keepalivecCs’|rt ¡|_tƒ}| t¡| |¡| |¡|dk rD|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ïrRrnrroÚ add_booleanÚaddÚ_logrrµrtr=r£r?rî)rruÚdatar=rwrgrgrhr~ês$        zTransport.global_requestcCsh|j ¡zLt|jƒdkr(|j d¡}n,|j |¡t|jƒdkrP|j d¡}nd}W5|j ¡X|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Ùrirjr«røÚpoprúr=)rrArUrgrgrhÚaccepts   zTransport.acceptr c Csˆ|dk r,t|tƒr dddg|_n | ¡g|_|j|| |p:|d| ¡|dk ræ|sæ| ¡} |  ¡| ¡ks||  ¡| ¡krÐ| t d¡| t d  | ¡t | ¡ƒ¡¡| t d  |  ¡t |  ¡ƒ¡¡t dƒ‚| t d   | ¡¡¡|dk s|dk s|s|r„|r*| t d ¡|  ||j|¡nZ|rH| t d ¡| |¡n<|dk rl| 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. Nrxryrz)rÎr7r8zBad 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¨rVÚ_preferred_keysrEr9rBrWÚasbytesr–rrµÚreprr_Úauth_gssapi_with_micrÎÚauth_gssapi_keyexÚauth_publickeyÚ auth_password) rZhostkeyÚusernameÚpasswordÚpkeyrÎZgss_authrrZ gss_trust_dnsrFrgrgrhr³(sv< ý ý ÿþ  ÿþ ÿþ ÿ ÿÿ      zTransport.connectcCs0|j ¡z|j}d|_|W¢S|j ¡XdS)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Ùrirjrärrgrgrhr>¨s zTransport.get_exceptioncOs0z|j ¡|||f|j|<W5|j ¡XdS)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Ùrjrirû)rÚnamerÚargsÚkwargsrgrgrhÚset_subsystem_handler¼s zTransport.set_subsystem_handlercCs|jo|jdk o|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/rrgrgrhr/Ðs ÿýzTransport.is_authenticatedcCs|jr|jdkrdS|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_usernamerrgrgrhr©ßszTransport.get_usernamecCs|jr|jdkrdS|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íZbannerrrgrgrhÚ 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 rV) r£rÔr_r¶rår ríÚ auth_noneÚwait_for_response©rr¡Úmy_eventrgrgrhr«øs   zTransport.auth_nonec sÒ|jr |jstdƒ‚|dkr&t ¡}n|}t|ƒ|_|j |ˆ|¡|dk rPgSz|j |¡WSt k rÌ}zP|r~d|j kr€‚z"‡fdd„}|  ||¡WWY¢Stk rº|‚YnXW5d}~XYnXdS)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 rVNúkeyboard-interactivecs*t|ƒdkrtdƒ‚t|ƒdkr$gSˆgS©NrœzFallback authentication failed.r©r«r_©ÚtitleÚ instructionsÚfields©r¢rgrhrYs   z(Transport.auth_password..handler) r£rÔr_r¶rår rír r¬rZÚ allowed_typesÚauth_interactive)rr¡r¢r@Úfallbackr®rrrgr¶rhr s&/    zTransport.auth_passwordcCs\|jr |jstdƒ‚|dkr&t ¡}n|}t|ƒ|_|j |||¡|dk rPgS|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 rVN) r£rÔr_r¶rår rírŸr¬)rr¡rFr@r®rgrgrhrŸis#   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, periodically 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 rV) r£rÔr_r¶rår rír¸r¬)rr¡rÚ submethodsr®rgrgrhr¸šs+  ÿzTransport.auth_interactivecCs|s dd„}| |||¡S)a Authenticate 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ÚappendÚinput©r³r´Z prompt_listZanswersÚpromptZ show_inputrgrgrhrÙs   z0Transport.auth_interactive_dumb..handler)r¸©rr¡rrºrgrgrhÚ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 rV) r£rÔr_r¶rår rírr¬)rr¡rÎrr®rgrgrhræ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 rV) r£rÔr_r¶rår ríržr¬r­rgrgrhrž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ì©rr¥rgrgrhÚset_log_channels  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érrgrgrhÚ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ÚhexdumprgrgrhrÊ0s 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_hexdumprrgrgrhrÌ<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ÚcompressrgrgrhÚuse_compressionGs zTransport.use_compressioncCs t|jddƒ}|dkrdS|ƒ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ÚgprgrgrhrÐXs zTransport.getpeernamecCsDd|_|j ¡| ¡r@|t ¡k r@|jjs@|jjs@|  d¡qdS)NFrš) r£r½r2Úis_aliver¶Úcurrent_threadrºÚ_closedÚclosedÚjoinrrgrgrhrfis ÿ þýüzTransport.stop_threadcGs@tt|ƒtƒr(|D]}|j ||¡qn|jj||f|žŽdSrd)Ú issubclassr­rRrëÚlog)rÚlevelÚmsgr¦rwrgrgrhr–~szTransport._logcCs|jS)z0used by KexGex to find primes for group exchange)rJrrgrgrhÚ_get_modulus_pack…szTransport._get_modulus_packcCsB|j}|j |¡dk r.|jdd@|_|j}q|jdd@|_|S)zyou are holding the lockNrœiÿÿÿ)rÞrÛr©rrvrgrgrhrm‰s zTransport._next_channelcCs|j |¡dS)z?used by a Channel to remove itself from the active channel listN)rÛÚdeleterÝrgrgrhÚ_unlink_channel’szTransport._unlink_channelcCs|j |¡dSrd)r½Ú send_message)rr—rgrgrhÚ _send_message–szTransport._send_messagecCs†t ¡}|j d¡|js*| td¡dS|j ¡|j ¡r@qf|j  ¡t ¡||j krt dƒ‚qz|  |¡W5|j  ¡XdS)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) r<rær=r£r–rrçrir?rjrèr_rá)rr—r;rgrgrhrt™s& ÿ   ÿzTransport._send_user_messagecCs ||_||_|jdkr||_dS)zR Used by a kex obj to set the K (root key) and H (exchange hash). N)rÓrÒrÊ)rÚkÚhrgrgrhÚ_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×)rZptypesrgrgrhÚ_expect_packet¼szTransport._expect_packetcCsP|j|jt|ƒƒ}|dkr$tdƒ‚| |jt|ƒ¡sFtd |j¡ƒ‚||_dS)NzUnknown host key typez#Signature verification ({}) failed.)Ú _key_inforËrRr_Zverify_ssh_sigrÒrµrÌ)rrÌÚsigrFrgrgrhÚ _verify_keyÂsÿÿzTransport._verify_keyc Cstƒ}| |j¡| |j¡| t|ƒ¡| |j¡t|j ddƒ}d  |j j j |¡}|dkrlt }|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)rRZ add_mpintrÓrŠrÒrnrbrÊrrÑrµÚ __class__Ú__name__rÚhasattrr–rÚsetattrr›Údigestr«) rr-ÚnbytesrwréZhash_select_msgr0ZsofarrîrgrgrhÚ _compute_keyÎs4   ÿ        zTransport._compute_keycCsb||jkrtd|ƒ‚nFt|j|d|ƒ|j|d|ƒtƒd}||jkrV| ¡S| ¡SdS)NzUnknown client cipher rŒr)Úbackend)r.r_rrÚ_ENCRYPTZ encryptorZ decryptor)rr¥rFZivZ operationÚcipherrgrgrhÚ _get_cipherìs ý zTransport._get_ciphercs&|dkr‡fdd„}|ˆ_n|ˆ_dS)Ncsˆ |¡dSrdrz)r|rrgrhr}ýsz=Transport._set_forward_agent_handler..default_handler)rá©rrr}rgrrhÚ_set_forward_agent_handlerús z$Transport._set_forward_agent_handlercs&|dkr‡fdd„}|ˆ_n|ˆ_dS)Ncsˆ |¡dSrdrz)r|Z src_addr_portrrgrhr}sz3Transport._set_x11_handler..default_handler)rârõrgrrhÚ_set_x11_handlers zTransport._set_x11_handlercCs6|j ¡z|j |¡|j ¡W5|j ¡XdSrd)rÙrirjrørÁrúÚnotify)rr|rgrgrhr{s   z!Transport._queue_incoming_channelcCs|dkr|j}tt|tƒSrd)ràrar6r8)rrZrgrgrhrkszTransport._sanitize_window_sizecCs|dkr|j}tt|tƒSrd)rßrar7r8)rr[rgrgrhrlszTransport._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õr;r/rRr&rnr r-Úget_textrr$rpr"ro)rÚptypeÚmessageZreplyrurvrgrgrhÚ_ensure_authed!s& ÿþý      zTransport._ensure_authedcCs2|jr.|js.t |d|›¡}td|›dƒ‚dS)a  Conditionally raise `MessageOrderError` during strict initial kex. This method should only be called inside code that handles non-KEXINIT messages; it does not interrogate ``ptype`` besides using it to log more accurately. zmsg z!In strict-kex mode, but was sent ú!N)r§rÔr=rr])rrûr¥rgrgrhÚ_enforce_strict_kexGs   ÿzTransport._enforce_strict_kexc Cs>t|_t |¡tt|ƒt@ƒ}|jr:| td  |¡¡n| td  |¡¡zÎz®|j   t |j dƒ¡| td  |j ¡¡| ¡|j  |j¡| ¡| t¡|jrü|j  ¡rÆ|jsÆ| ¡z|j  ¡\}}Wntk rðYq¦YnX|tkr | |¡q¦n:|tkr$| |¡qün |tkrD| |¡| |¡q¦t|j ƒdkr®||j kr‚t!}|j"rpt#}|d  |j |¡ƒ‚t$ƒ|_ |dkr®|dkr®|j% &||¡q¦||j'krê| (||¡}|rØ| )|¡n|j'||ƒn||j*kr^| +¡}|j, -|¡}|dk r&|j*|||ƒn6||j.krF| td   |¡¡n| t/d   |¡¡qün’|j0dk r ||j0j'kr |j0j'|}||ƒt|j ƒdkrðq¦nPt1|} d   || ¡} | t2| ¡|t3krðt4ƒ} |  5t6¡|  7|j8¡| )| ¡|j  9¡q¦Wnbt!k r\} z:| t/d   |jr*d nd| ¡¡| t/t: ;¡¡| |_j?k r} zft@| jAƒt$krê| jArÖd  | jAd| jAd¡} ntB| ƒpætC| ƒ} n| jA} | t/d| ¡| |_U s z,Transport._send_kex_init..Nrcsg|]}| ˆ¡s|‘qSrgr&r(r)rgrhr*Y s þú ext-info-cÚsÚcú kex-strict-ú-v00@openssh.comr‹)'rçrirjrærrÍrÕrRr'rõrJr«r5r&Úfilterr÷r"Ú __contains__r$rÁr¦rRrnrrŠrˆr‰Zadd_listr r!r)roÚbytesr”rpr›rÄÚ_latest_kex_initrá)rZ kex_algosZkex_mpZpkexÚavailable_server_keysrrwrgr)rhrŒF sV    þ  öÿ              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_booleanr)rrwÚignore_first_byteÚparsedrgrgrhÚ_really_parse_kex_initŽ s"            z Transport._really_parse_kex_initcCs|jt|jƒddS)NT)rB)rDrRr3rrgrgrhÚ_get_latest_kex_init¡ 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|_g}t|ƒD]„\}}| d¡rD||_|  d|¡nZ| d¡r|j r\d nd!}d|›d"}||koz|j |_ | td#|j ›¡|  d|¡q|D]}|  |¡q¦|j rÜ|jsÜ|jdkrÜtd$ƒ‚|j røtt|jj|ƒƒ}ntt|j|jƒƒ}t|ƒdkr td%ƒ‚|j|d|ƒ|_| td& |d¡¡|j r€ttt|j ¡ƒj|jƒƒ}tt|j|ƒƒ}ntt|j|jƒƒ}t|ƒdkr¨td'ƒ‚|d|_|j rÐ| ¡dkrÐtd(ƒ‚| d)|d|d¡|j rtt|jj|ƒƒ}tt|jj|ƒƒ}n$tt|j|jƒƒ}tt|j|jƒƒ}t|ƒdksTt|ƒdkr\td*ƒ‚|d|_ |d|_!|jd+|j |j!d,|j r²tt|j"j|ƒƒ}tt|j"j|ƒƒ}n$tt|j|j"ƒƒ}tt|j|j"ƒƒ}t|ƒdksòt|ƒdkrútd-ƒ‚|d|_#|d|_$|jd.|j#|j$d,|j rPtt|j%j| ƒƒ}tt|j%j| ƒƒ}n$tt| j|j%ƒƒ}tt| j|j%ƒƒ}t|ƒdkst|ƒdkr°d/}|d07}t| |||j%¡ƒ‚|d|_&|d|_'|jd1|j&|j'd,| td2¡t(| )¡|_*dS)3Nr5r6r7r8r9r: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-rr.r-r,r/zStrict kex mode: z9In strict-kex mode, but KEXINIT was not the first packet!z3Incompatible 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 ===)+rDr–rr×rµÚ_remote_ext_infoZ_remote_strict_kexÚ enumerater'rKrõr¦r§r˜rÔrr]rRr0r'r1r«r\Ú _kex_inforÑr÷r"r$rËrIrr rÂrÃr!rÆrÇr)rÈrÉrZ get_so_farrÅ)rrwrCr5r6r7r8r9r:r;r<r=r>r?ÚprefixÚvalueZto_popr#ÚalgorÚexpectedZ agreed_kexr4Z agreed_keysZagreed_local_ciphersZagreed_remote_ciphersZagreed_remote_macsZagreed_local_macsZagreed_remote_compressionZagreed_local_compressionrÛrgrgrhr§ s˜  ô       ÿ ÿÿþýÿ ÿ ÿÿþÿÿÿ ÿÿ ÿþÿþÿþÿþÿÿ  ÿ ÿ ÿ ÿ ÿÿ  ÿþÿþÿþÿþÿ ÿ þýÿ  ý zTransport._parse_kex_initc CsH|j|jd}|jr<| d|¡}| d|j|jd¡}n$| d|¡}| d|j|jd¡}| |j|||j¡}d|jk}|j|jd}|j|jd }|jr¶| d |ƒj¡}n| d |ƒj¡}|j j ||||||d |j |j d } | dk r&|j dks |j r&| td¡|j  | ƒ¡|jrD| td¡|j  ¡dS)zLswitch on newly negotiated encryption parameters for inbound trafficrŽÚAÚCrÚBÚDúetm@openssh.comr”rŒÚEÚF©ÚetmrœNr˜ú$Switching on inbound compression ...z8Resetting inbound seqno after NEWKEYS due to strict mode)r.rÃrõrðrôÚ_DECRYPTrÇÚ _mac_infoÚ digest_sizer½Zset_inbound_cipherÚ_compression_inforÉrÖr–rÚset_inbound_compressorr§Zreset_seqno_in) rÚ block_sizeZIV_inZkey_inÚenginerUÚmac_sizeÚ mac_engineÚmac_keyÚ compress_inrgrgrhÚ_activate_inbound‘ s\ ÿ ÿÿ ÿ ÿÿ þzTransport._activate_inboundc Cs tƒ}| t¡| |¡|jr6| td¡|j ¡|j |j d}|j rr|  d|¡}|  d|j |j d¡}n$|  d|¡}|  d|j |j d¡}|  |j |||j¡}d|jk}|j|jd }|j|jd }|j rì|  d |ƒj¡} n|  d |ƒj¡} |j  d ¡} |jj||||| | |d|j|jd} | dk rj|jdksP|jrj| td¡|j | ƒ¡|j ¡s|d|_|j rü|jrü|jdkrüdd |j¡i} tƒ}| t¡| t | ƒ¡t!|  "¡ƒD]\} }| #| ¡| #|¡qÒ| |¡| $t%¡dS)zMswitch on newly negotiated encryption parameters for outbound trafficz9Resetting outbound seqno after NEWKEYS due to strict moderŽrOrPrrMrNrQr”rŒrSrRz-ctrrTrNr˜ú%Switching on outbound compression ...Fr+zserver-sig-algsú,)&rRrnrrár§r–rr½Zreset_seqno_outr.rÂrõrðrôròrÆrXrYÚendswithZset_outbound_cipherrZrÈrÖÚset_outbound_compressorrrÕrôrFr×r%r?rpr«ÚsortedÚitemsrorår)rrwr\ZIV_outZkey_outr]rUr^r_r`ZsdctrÚ compress_outÚ extensionsr¥rJrgrgrhÚ_activate_outbound¼ sˆ  þ  ÿ ÿÿ  ÿ ÿÿ  ÿþý   zTransport._activate_outboundcCsrd|_|jdkr:|j|jd}| td¡|j |ƒ¡|jdkrn|j|jd}| td¡|j |ƒ¡dS)NTr˜rrcrœrV) rÖrÈrZr–rr½rfrÉr[)rrirargrgrhÚ _auth_triggerý s    zTransport._auth_triggercCsJi}t| ¡ƒD]}| ¡}| ¡}|||<q| td |¡¡||_dS)NzGot EXT_INFO: {})r rrúÚ get_stringr–rrµr¥)rrÛrjÚ_r¥rJrgrgrhrü s zTransport._parse_ext_infocCs¨| td¡| ¡d|_|_d|_d|_|jrF|jdkrFt |ƒ|_|j sZd|_ |j _ |j dk rn|j  ¡|j  ¡s~d|_|j ¡z|j ¡W5|j ¡XdS)NzSwitch to new keys ...TF)r–rrbrÄrÅrÓrÑrõrír rÔr½Z_initial_kex_donerïr rrÕrçrirjrærrgrgrhrý s$        zTransport._parse_newkeyscCs(| ¡}| ¡}| td ||¡¡dS)NzDisconnect (code {:d}): {})rrúr–rrµ)rrwÚcodeÚdescrgrgrhr3 szTransport._parse_disconnectc Cs| ¡}| td |¡¡| ¡}|js@| td |¡¡d}nl|dkrr| ¡}| ¡}|j ||¡}|r¬|f}n:|dkrž| ¡}| ¡}|j  ||¡d}n|j  ||¡}d}t |ƒt krÄ|}d}|rüt ƒ}|rè| t¡|j|Žn | t¡| |¡dS)NzReceived global request "{}"z*Rejecting "{}" global request from server.Frxr„Trg)rúr–rrµrArõrröZcheck_port_forward_requestZcancel_port_forward_requestZcheck_global_requestr­r®rRrnrr•r rá) rrwruZ want_replyÚokr€r ÚextrarÛrgrgrhrþ8 s@þ    zTransport._parse_global_requestcCs*| td¡||_|jdk r&|j ¡dS)NzGlobal request successful.©r–rrîrïr rrgrgrhrÿ\ s  z Transport._parse_request_successcCs*| td¡d|_|jdk r&|j ¡dS)NzGlobal request denied.rsrrgrgrhrb s  z Transport._parse_request_failurecCs¤| ¡}| ¡}| ¡}| ¡}|j |¡}|dkrD| td¡dS|j ¡zD| |||¡| t d  |¡¡||j kr|j |  ¡|j |=W5|j ¡XdS)Nz%Success for unrequested channel! [??]zSecsh channel {:d} opened.) rrÛrr–rrÙrirjÚ_set_remote_channelrrµrÜr )rrwrvZ server_chanidZserver_window_sizeZserver_max_packet_sizerUrgrgrhrh s*   ÿ   z%Transport._parse_channel_open_successcCs¤| ¡}| ¡}| ¡}| ¡t |d¡}| td |||¡¡|j ¡zFt ||ƒ|_ ||j kr|j  |¡||j kr|j | ¡|j |=W5|j  ¡XdS)Nz(unknown code)z&Secsh channel {:d} open FAILED: {}: {})rrúr!rr–rrµrÙrirjr[rärÜrÛrÞr )rrwrvr Z reason_strZ reason_textrgrgrhr~ s. ÿþ       z%Transport._parse_channel_open_failurecCsh| ¡}| ¡}| ¡}| ¡}d}|dkrj|jdk rj| td¡|j ¡z | ¡}W5|j ¡Xnˆ|dkrÈ|j dk rÈ| ¡}| ¡} | td  || ¡¡|j ¡z | ¡}W5|j ¡Xn*|dkr8|j dk r8| ¡} | ¡} | ¡}| ¡} | td  || ¡¡|j ¡z | ¡}W5|j ¡Xnº|j s\| td  |¡¡d }t } n–|j ¡z | ¡}W5|j ¡X|d krÄ| ¡} | ¡}| ¡}| ¡} |j ||| f| |f¡} n|j ||¡} | tkrò| td   |¡¡d }|r>tƒ}| t¡| |¡| | ¡| d ¡| d ¡| |¡dSt|ƒ}|j ¡zD|j ||¡d |j|<| |¡| |j|j¡|  |||¡W5|j ¡Xtƒ}| t!¡| |¡| |¡| |j¡| |j¡| |¡| td  ||¡¡|dkr| |¡nR|dkr.|  ||| f¡n6|dkrZ|| f|_"|  ||| f| | f¡n | #|¡dS)NFrbz!Incoming forward agent connectionr_z$Incoming x11 connection from {}:{:d}rdz.Incoming tcp forwarded connection from {}:{:d}z+Rejecting "{}" channel request from server.Trhz+Rejecting "{}" channel request from client.r rùzSecsh channel {:d} ({}) opened.)$rúrrár–rrÙrirjrmrârµrãrõr"röZ"check_channel_direct_tcpip_requestZcheck_channel_requestr#rRrnr$rprorárrÛrqrÝrrrsràrßrtr%Ú origin_addrr{)rrwrurvZinitial_window_sizer[ZrejectZ my_chanidruÚ origin_portZ server_addrZ server_portr reZ dest_portrÛrUrgrgrhr– söÿþ   ÿþ  ÿþ  þ    ýÿ þ         ÿÿ        ÿ     ÿzTransport._parse_channel_opencCs4| ¡| ¡}| ¡| td t |¡¡¡dS)Nz Debug msg: {})rArmr–rrµr Z safe_string)rrwrÛrgrgrhr szTransport._parse_debugcCsBz0|j ¡||jkr$dgifW¢S|j|W¢S|j ¡XdSrdr¤rÇrgrgrhÚ_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òrWr¾rµÚparamikoÚ __version__r¿Ú_preferred_ciphersÚ_preferred_macsršZ_preferred_pubkeysrÐrEZ is_availablerÏrÍrZAESr ZCTRZCBCrcr.rrrrrXrVrCrWrDrærHrIrFrGrJrKrPrQrOrLrMrNrHrArBrZrJr¼r9r:r¸rÚpropertyr r!r$r%r'r)r1r3r5r9rBrDrGrIÚ staticmethodrQr2rWrXr^rarcrfr]rƒr…r†r‹rŽr’r~r™r³r>r¨r/r©rªr«r rŸr¸rÆrržrÈrÉrÊrÌrÏrÐrfr–rÜrmrßrárträrårèrðrôrör÷r{rkrlrýrÿrrrrrŒrDrErrbrkrlrürýrrþrÿrrrrrrwr.rZ_request_successr/Z_request_failedr0Z_feedr1Z_feed_extendedr2Z_window_adjustr3Z_handle_requestr4Z _handle_eofr5Z _handle_closerrgrgrgrhrj˜sæ       üüüüüüüÛ.øìô ú ö n        " : B (  ÿ # ù _ 6  % ö    U 1 5         &-  +H k+A $~ ørjc@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)r4a: 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 ||_dSrd)r‚)rÚ transportrgrgrhr¸A szSecurityOptions.__init__cCs d |j¡S)r*z#)rµr‚rrgrgrhr1D szSecurityOptions.__repr__cstt|ƒtkrt|ƒ}t|ƒtk r(tdƒ‚tt|j|ƒ ¡ƒ‰‡fdd„|Dƒ}t|ƒdkrbtdƒ‚t |j||ƒdS)Nzexpected tuple or listcsg|]}|ˆkr|‘qSrgrg)rÚn©Úpossiblergrhr*P sz(SecurityOptions._set..rzunknown cipher) r­rRr®Ú TypeErrorrr‚r"r«Ú ValueErrorrí)rr¥ÚorigrÚ forbiddenrgr…rhÚ_setJ s   zSecurityOptions._setcCs|jjS)zSymmetric encryption ciphers)r‚r~rrgrgrhrU szSecurityOptions.cipherscCs| dd|¡dS)Nr~r.©r‹©rrrgrgrhrZ scCs|jjS)z Digest (one-way hash) algorithms)r‚rrrgrgrhÚdigests^ szSecurityOptions.digestscCs| dd|¡dS)NrrXrŒrrgrgrhrŽc scCs|jjS)zPublic-key algorithms)r‚ršrrgrgrhÚ key_typesg szSecurityOptions.key_typescCs| dd|¡dS)NršrærŒrrgrgrhrl scCs|jjS)zKey exchange algorithms)r‚rÐrrgrgrhr&p szSecurityOptions.kexcCs| dd|¡dS)NrÐrHrŒrrgrgrhr&u scCs|jjS)zCompression algorithms)r‚rÍrrgrgrhr(y szSecurityOptions.compressioncCs| dd|¡dS)NrÍrZrŒrrgrgrhr(~ sN)rërxryrzÚ __slots__r¸r1r‹r€rÚsetterrŽrr&r(rgrgrgrhr42 s2           r4c@s<eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd S)rÚcCst ¡|_t ¡|_dSrd)rÚWeakValueDictionaryÚ_mapr¶rØÚ_lockrrgrgrhr¸„ s zChannelMap.__init__cCs*|j ¡z||j|<W5|j ¡XdSrd)r”rirjr“)rrvrUrgrgrhrq‰ s zChannelMap.putcCs.|j ¡z|j |d¡W¢S|j ¡XdSrd)r”rirjr“rrÝrgrgrhr s zChannelMap.getcCsB|j ¡z&z |j|=Wntk r,YnXW5|j ¡XdSrd)r”rirjr“rHrÝrgrgrhrÞ— s   zChannelMap.deletecCs.|j ¡zt|j ¡ƒW¢S|j ¡XdSrd)r”rirjrRr“rSrrgrgrhrS¡ s zChannelMap.valuescCs*|j ¡zt|jƒW¢S|j ¡XdSrd)r”rirjr«r“rrgrgrhÚ__len__¨ s zChannelMap.__len__N) rërxryr¸rqrrÞrSr•rgrgrgrhrÚƒ s  rÚcsveZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zdd d„Z dd„Z ddd„Z ddd„Z dd„Z dd„Z‡ZS)ÚServiceRequestingTransportzd Transport, but also handling service requests, like it oughtta! .. versionadded:: 3.2 cs$tƒj||Žd|_|j|jt<dS)NF)Úsuperr¸Ú_service_userauth_acceptedÚ_parse_service_acceptrr*)rr¦r§©rêrgrhr¸» sz#ServiceRequestingTransport.__init__cCs<| ¡}|dkr&| td |¡¡dSd|_| td¡dS)Nú ssh-userauthz!Service request "{}" accepted (?)Tz+MSG_SERVICE_ACCEPT received; auth may begin)rúr–rrµr˜)rrwZservicergrgrhr™À sÿz0ServiceRequestingTransport._parse_service_acceptcCsn|jr |jstdƒ‚|jrdStƒ}| t¡| d¡| t d¡|  |¡|js`t   d¡qN|  ¡|_dS)NrVr›z)Sending MSG_SERVICE_REQUEST: ssh-userauthrš)r£rÔr_r˜rRrnr)ror–rrár<ÚsleepÚget_auth_handlerrírrgrgrhÚensure_sessionÕ s      z)ServiceRequestingTransport.ensure_sessioncCst|ƒSrd)r rrgrgrhrù sz+ServiceRequestingTransport.get_auth_handlercCs| ¡|j |¡Srd)ržrír«©rr¡rgrgrhr«ý sz$ServiceRequestingTransport.auth_noneTc sŒ| ¡z|j |ˆ¡WStk r†}zP|r8d|jkr:‚z"‡fdd„}| ||¡WWY¢Stk rt|‚YnXW5d}~XYnXdS)Nr¯cs*t|ƒdkrtdƒ‚t|ƒdkr$gSˆgSr°r±r²r¶rgrhr s   z9ServiceRequestingTransport.auth_password..handler)ržrír rZr·r¸r_)rr¡r¢r¹rrrgr¶rhr  s z(ServiceRequestingTransport.auth_passwordcCs| ¡|j ||¡Srd)ržrírŸ)rr¡rFrgrgrhrŸ sz)ServiceRequestingTransport.auth_publickeyr cCs| ¡|j |||¡Srd)ržrír¸rÅrgrgrhr¸# s ÿz+ServiceRequestingTransport.auth_interactiveNcCs"| ¡|sdd„}| |||¡S)NcSsRg}|rt| ¡ƒ|r$t| ¡ƒ|D]$\}}t| ¡dd| tƒ¡q(|Sr»r¾rÃrgrgrhr2 s   zAServiceRequestingTransport.auth_interactive_dumb..handler)ržr¸rÅrgrgrhrÆ* s z0ServiceRequestingTransport.auth_interactive_dumbcCs"| ¡| ¡|_|j |||¡Srd)ržrrír)rr¡rÎrrgrgrhr? s ÿz/ServiceRequestingTransport.auth_gssapi_with_miccCs| ¡| ¡|_|j |¡Srd)ržrríržrŸrgrgrhržG s z,ServiceRequestingTransport.auth_gssapi_keyex)T)r )Nr )rërxryrzr¸r™ržrr«r rŸr¸rÆrržÚ __classcell__rgrgršrhr–° s $   r–)rzrˆr¯rr¶r<rÚhashlibrrrrZcryptography.hazmat.backendsrZ&cryptography.hazmat.primitives.ciphersrrr r|r Zparamiko.auth_handlerr r 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=r>r?r@Zparamiko.compressrArBZparamiko.dsskeyrCZparamiko.ed25519keyrDZparamiko.kex_curve25519rEZparamiko.kex_gexrFrGZparamiko.kex_group1rHZparamiko.kex_group14rIrJZparamiko.kex_group16rKZparamiko.kex_ecdh_nistrLrMrNZparamiko.kex_gssrOrPrQZparamiko.messagerRZparamiko.packetrSrTZparamiko.primesrUZparamiko.rsakeyrVZparamiko.ecdsakeyrWZparamiko.serverrXZparamiko.sftp_clientrYZparamiko.ssh_exceptionrZr[r\r]r^r_Z paramiko.utilr`rarbZ/cryptography.hazmat.decrepit.ciphers.algorithmsrcÚ ImportErrorZ1cryptography.hazmat.primitives.ciphers.algorithmsreriÚatexitÚregisterr·rjr4rÚr–rgrgrgrhÚsŠ    Ð4             1Q-