Dec-06-2018, 01:04 PM
Hi,
Sorry for the late reply!
I tried what you suggested but i get the error below
Sorry for the late reply!
I tried what you suggested but i get the error below
C:\Users\Comp1\Documents\Work\Old>Host_FingerPrint_SFTP.py Yay.txt Traceback (most recent call last): File "C:\Users\Comp1\Documents\Work\Old\Host_FingerPrint_SFTP.py", line 16, in <module> key = paramiko.ed25519key.Ed25519Key(data=decodebytes(keydata).hex()) File "C:\Users\Comp1\AppData\Local\Programs\Python\Python37-32\lib\site-p ackages\paramiko\ed25519key.py", line 66, in __init__ msg = Message(data) File "C:\Users\Comp1\AppData\Local\Programs\Python\Python37-32\lib\site-p ackages\paramiko\message.py", line 52, in __init__ self.packet = BytesIO(content) TypeError: a bytes-like object is required, not 'str'using the following code
import pysftp import sys import paramiko from paramiko.py3compat import decodebytes import base64 path = './folder/' + sys.argv[1] #hard-coded localpath = sys.argv[1] remote_path = "./work/" #hard-coded host = "1.2.3.4" #hard-coded password = "password" #hard-coded username = "username" #hard-coded keydata = b"""RLhdtbhVbFXUeqZh6jm0t5ToI6b4IGbac8R2EkP+Ido=""" #obtained using filezilla, connected successfully then used lock icon on the bottom right to display fingerprints: SHA256: RLh...kP+Ido= key = paramiko.ed25519key.Ed25519Key(data=decodebytes(keydata).hex()) cnopts = pysftp.CnOpts() cnopts.hostkeys.add('1.2.3.4', 'ssh-ed25519', key) with pysftp.Connection(host, username=username, password=password, cnopts=cnopts) as sftp: sftp.put(localpath, path) print("Upload done")is there a library that i need apart from base64?