Skip to content

Commit b87291d

Browse files
committed
Add support for sending and receiving EXT_INFO messages from the client
This commit adds support for accepting and parsing EXT_INFO messages from SSH clients when AsyncSSH is acting as a server, and for sending an EXT_INFO message containing the "global-requests-ok" extension when AsyncSSH is acting as a client and the server supports client extensions. Since AsyncSSH doesn't currently disable sending global requests based on the advertised client software and version, it doesn't currently do anything different when receiving the 'global-requests-ok' extension. However, this change provides the support to easily parse client extensions that might be needed in the future.
1 parent ef96070 commit b87291d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

asyncssh/connection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def _choose_alg(self, alg_type, local_algs, remote_algs):
846846
def _get_ext_info_kex_alg(self):
847847
"""Return the kex alg to add if any to request extension info"""
848848

849-
return [b'ext-info-c'] if self.is_client() else []
849+
return [b'ext-info-c'] if self.is_client() else [b'ext-info-s']
850850

851851
def _send(self, data):
852852
"""Send data to the SSH connection"""
@@ -1548,6 +1548,9 @@ def _process_kexinit(self, _pkttype, _pktid, packet):
15481548
else:
15491549
self._server_kexinit = packet.get_consumed_payload()
15501550

1551+
if b'ext-info-s' in peer_kex_algs and not self._session_id:
1552+
self._can_send_ext_info = True
1553+
15511554
if self._kexinit_sent:
15521555
self._kexinit_sent = False
15531556
else:
@@ -1718,6 +1721,10 @@ def _process_userauth_success(self, _pkttype, pktid, packet):
17181721
self._set_keepalive_timer()
17191722
self._owner.auth_completed()
17201723

1724+
if self._can_send_ext_info:
1725+
self._extensions_sent[b'global-requests-ok'] = b''
1726+
self._send_ext_info()
1727+
17211728
if self._acceptor:
17221729
result = self._acceptor(self)
17231730

0 commit comments

Comments
 (0)