I've been digging around and have tried several solutions but can't get anything to work. I'm trying to run a python script to download a specific folder via SFTP. I've been trying to follow the instructions here: https://pysftp.readthedocs.io/en/release_0.2.9/ but having no luck when I run this:
import pysftp
with pysftp.Connection(host="sftp.url.com",username="username",password="password",port="##",private_key="C:\location\location"):
with sftp.cd('public'):
sftp.get('/todaysdate')
Want to be able to grab a single file and download it to a local folder.
Thanks in advance and apologies if this is a basic question, been doing lots of digging but haven't had any luck finding a solution.
Here is the error message I am receiving:
Warning (from warnings module):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pysftp\__init__.py", line 61
warnings.warn(wmsg, UserWarning)
UserWarning: Failed to load HostKeys from M:\\.ssh\known_hosts. You will need to explicitly load HostKeys (cnopts.hostkeys.load(filename)) or disableHostKey checking (cnopts.hostkeys = None).
Traceback (most recent call last):
File "C:\BBG API\keytest2.py", line 3, in <module>
with pysftp.Connection(host="sftp.url.com",username="user",password="pass",port="##",private_key="C:/CSV/filename"):
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pysftp\__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pysftp\__init__.py", line 71, in get_hostkey
raise SSHException("No hostkey for host %s found." % host)
paramiko.ssh_exception.SSHException: No hostkey for host sftp.trafix.com found.