From f3eedd04b4f5fa334da45105fc6862bbc2dd4c09 Mon Sep 17 00:00:00 2001 From: 8ar10der <8ar10der@amao.run> Date: Wed, 6 Mar 2024 17:04:26 +0100 Subject: [PATCH] Add ssh2-python keyboard_interactive supporting --- pssh/clients/native/single.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pssh/clients/native/single.py b/pssh/clients/native/single.py index 3a225b55..319583c0 100644 --- a/pssh/clients/native/single.py +++ b/pssh/clients/native/single.py @@ -61,6 +61,7 @@ def __init__(self, host, _auth_thread_pool=True, keepalive_seconds=60, identity_auth=True, ipv6_only=False, + keyboard_interactive=False, ): """ :param host: Host name or IP to connect to. @@ -107,6 +108,8 @@ def __init__(self, host, for the host or raise NoIPv6AddressFoundError otherwise. Note this will disable connecting to an IPv4 address if an IP address is provided instead. :type ipv6_only: bool + :param keyboard_interactive: (Optional) Set to True to enable authentication as keyboard-interactive + :type keyboard_interactive: bool :raises: :py:class:`pssh.exceptions.PKeyFileError` on errors finding provided private key. @@ -119,6 +122,7 @@ def __init__(self, host, self.alias = alias self.host = host self.port = port if port is not None else 22 + self.keyboard_interactive = keyboard_interactive if proxy_host is not None: _port = port if proxy_port is None else proxy_port _pkey = pkey if proxy_pkey is None else proxy_pkey @@ -260,7 +264,10 @@ def _pkey_from_memory(self, pkey_data): ) def _password_auth(self): - self.session.userauth_password(self.user, self.password) + if self.keyboard_interactive: + self.session.userauth_keyboardinteractive(self.user, self.password) + else: + self.session.userauth_password(self.user, self.password) def _open_session(self): chan = self._eagain(self.session.open_session)