0

I found bunch of information about how put file if you DON'T have a hostkey,

But couldn't find anything about How to put file on SFTP server having a hostkey.

So I have my hostkey . Where should I place it in a code?

import pysftp as sftp

def sftpExample():
    try:
        hostkey = '12345642121' # My hostkey
        s = sftp.Connection(host='Host.com',username='MuUserName',password='MyPassword')
        remotepath = 'path/Example/TestFile.txt' 
        localpath = r'\\Path\Example\TestFile.txt'
        s.put(localpath,remotepath)
        s.close()
    except Exception as e:
        print (str(e))

sftpExample()
Serdia
  • 4,242
  • 22
  • 86
  • 159
  • 1
    [Verify host key with pysftp](https://stackoverflow.com/questions/38939454/verify-host-key-with-pysftp) – furas Oct 08 '19 at 23:50
  • Thanks, but I do not want unsecured connection. Second, I tried that, doesn't work – Serdia Oct 08 '19 at 23:51
  • Thanks. But getting an error now: `'utf-8' codec can't decode byte 0xe9 in position 2: invalid continuation byte`. https://stackoverflow.com/questions/58309346/utf-8-codec-cant-decode-byte-0xe9-in-position-2-invalid-continuation-byte – Serdia Oct 09 '19 at 17:29

0 Answers0