Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
potench committed Oct 2, 2024
1 parent 5193bde commit 836e946
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tap_sftp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit 836e946

Please sign in to comment.