S
S
shell_guy2021-11-10 11:38:29
Python
shell_guy, 2021-11-10 11:38:29

Why is the file not copied from the remote host to the local host?

Good day, I'm trying to download a file from a linux host to win, but I get a trace. error:

C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Backup>p.py
C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\pysftp\_
_init__ .py:61: UserWarning: Failed to load HostKeys from C:\Users\admin\.ssh\kno
wn_hosts. You will need to explicitly load HostKeys (cnopts.hostkeys.load(filen
ame)) or disableHostKey checking (cnopts.hostkeys = None).
warnings.warn(wmsg, UserWarning)
Traceback (most recent call last):
File "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\Backup\p.py
", line 15, in
with pysftp.Connection(host=myHostname, username=myUsername, password=myPass
word, port=myPort) as sftp:
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\
pysftp\__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\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 192.168.2.11 found.
Exception ignored in:
Traceback (most recent call last):
File "C:
pysftp\__init__.py", line 1013, in __del__
self.close()
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\
pysftp\__init__.py", line 784, in close
if self._sftp_live:
AttributeError: 'Connection' object has no attribute '_sftp_live

'

import pysftp

myHostname = "192.168.2.11"
myUsername = "admin"
myPassword = "pwd"
myPort = "22"

with pysftp.Connection(host=myHostname, username=myUsername, password=myPassword, port=myPort) as sftp:
    print ("Connection succesfully stablished ... ")

   
    remoteFilePath = '/share/MD0_DATA/MSSQL/Backup.bak'

  
    localFilePath = 'C:/'

    sftp.get(remoteFilePath, localFilePath)


What needs to be added/corrected to make it work? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-11-10
@shell_guy

No hostkey for host 192.168.2.11 found

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question