From 836e946d2aa9d47358c43683fe4b822e4e3c598e Mon Sep 17 00:00:00 2001 From: Christian Shum-Harden Date: Wed, 2 Oct 2024 14:47:09 -0700 Subject: [PATCH] fix --- tap_sftp/client.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tap_sftp/client.py b/tap_sftp/client.py index ce794a3..c77f8c6 100644 --- a/tap_sftp/client.py +++ b/tap_sftp/client.py @@ -54,17 +54,18 @@ def __connect(self): def _attempt_connection(self): client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect( - hostname=self.host, - port=self.port, - username=self.username, - password=self.password, - pkey=self.key, - compress=True, - timeout=120 - ) - self.sftp = client.open_sftp() - + client.get_transport().get_security_options().key_types = ['ssh-rsa', 'ecdsa-sha2-nistp256'] + try: + client.connect( + hostname=self.host, + port=self.port, + username=self.username, + password=self.password, + pkey=self.key, + compress=True, + timeout=120 + ) + self.sftp = client.open_sftp() except paramiko.AuthenticationException: print("Authentication failed, please verify your credentials.") except paramiko.SSHException as sshException: @@ -76,6 +77,7 @@ def _attempt_connection(self): finally: if client: client.close() + def close(self): if self.sftp is not None: self.sftp.close()