pysftp connection issue - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: pysftp connection issue (/thread-37249.html) |
pysftp connection issue - geil007 - May-18-2022 hi all, i am trying to connect to an AWS hosted SFTP server from my Azure Databricks Notebook. import pysftp as sftp from base64 import decodebytes import paramiko keydata = b"""AAAAB3NzaC1yc2EAAAADAQABAAABAQC5EVdi40ppCS+ctFidNOUxKOkzZbKkHzWYMnM+q3qvqqiouNSWlpU/zNinxIh5mQPCZnzK67dhhJfIzIoRiZ4D9/geTEeWqOtf4LjDveGEx/WCU6sjL1IUQFFa /1oI8SyfYKwzxLNcJ7nRBCpwrnDngLPuYEurDTdy5lx8MP6VLlLqm3nGN77YtB+vuQKBZ437uduVy6xH0abcuB6H3S26EfyQoWZBJng1jn/O2yXvNhtNpVMKueCuW4NXbJoqPAU9/U6F0YGH9w2qsXFXdfdBUljonEady0vnB2ieAnUe7q1QTJ6MX+UvrEyg/EK7xHNe4GgBWM5dfRXF56B2tbYn""" key = paramiko.RSAKey(data=decodebytes(keydata)) cnopts = pysftp.CnOpts() cnopts.hostkeys.add('s-936a09baf53d41da9.server.transfer.eu-central-1.amazonaws.com', 'ssh-rsa', key) with pysftp.Connection('s-936a09baf53d41da9.server.transfer.eu-central-1.amazonaws.com', 'user', 'xxxx', cnopts=cnopts) as sftp: #with sftp.cd('/pmd-bisnode-dnb/test/'): # temporarily chdir to allcode print(sftp.listdir()) #sftp.get('Bayer_CMPELK_DEV_20210326045204_SEEDFILE_HEADER.json')but getting the SSH Exception error: I have generated the keydata above using: ssh-keyscan s-936a09baf53d41da9.server.transfer.eu-central-1.amazonaws.comIf I don't set the "cnopts" attribute in the Connection, then i get the SSH Exception: No hostkey for host s-936a09baf53d41da9.server.transfer.eu-central-1.amazonaws.com found. I have checked the AWS SFTP logs, but the request has not even reached there, so there is no logging information. I am complete lost as to what am I doing wrong here. Any help or pointer shall really be appreciated, thanks. |