@@ -97,45 +97,6 @@ async def _close(self) -> None:
9797 close = sync_wrapper (_close )
9898
9999
100- # NOTE: Github's SSH server does not strictly comply with the SSH protocol.
101- # When validating a public key using the rsa-sha2-256 or rsa-sha2-512
102- # signature algorithms, RFC4252 + RFC8332 state that the server should respond
103- # with the same algorithm in SSH_MSG_USERAUTH_PK_OK. Github's server always
104- # returns "ssh-rsa" rather than the correct sha2 algorithm name (likely for
105- # backwards compatibility with old SSH client reasons). This behavior causes
106- # asyncssh to fail with a key-mismatch error (since asyncssh expects the server
107- # to behave properly).
108- #
109- # See also:
110- # https://www.ietf.org/rfc/rfc4252.txt
111- # https://www.ietf.org/rfc/rfc8332.txt
112- def _process_public_key_ok_gh (self , _pkttype , _pktid , packet ):
113- from asyncssh .misc import ProtocolError
114-
115- algorithm = packet .get_string ()
116- key_data = packet .get_string ()
117- packet .check_end ()
118-
119- # pylint: disable=protected-access
120- if (
121- (
122- algorithm == b"ssh-rsa"
123- and self ._keypair .algorithm
124- not in (
125- b"ssh-rsa" ,
126- b"rsa-sha2-256" ,
127- b"rsa-sha2-512" ,
128- )
129- )
130- or (algorithm not in (b"ssh-rsa" , self ._keypair .algorithm ))
131- or key_data != self ._keypair .public_data
132- ):
133- raise ProtocolError ("Key mismatch" )
134-
135- self .create_task (self ._send_signed_request ())
136- return True
137-
138-
139100class InteractiveSSHClient (SSHClient ):
140101 _conn : Optional ["SSHClientConnection" ] = None
141102 _keys_to_try : Optional [list ["FilePath" ]] = None
@@ -286,12 +247,6 @@ async def _run_command(
286247 key_filename: Optional path to private keyfile
287248 """
288249 import asyncssh
289- from asyncssh .auth import MSG_USERAUTH_PK_OK , _ClientPublicKeyAuth
290-
291- # pylint: disable=protected-access
292- _ClientPublicKeyAuth ._packet_handlers [MSG_USERAUTH_PK_OK ] = (
293- _process_public_key_ok_gh
294- )
295250
296251 try :
297252 conn = await asyncssh .connect (
0 commit comments