Nov-30-2018, 08:31 PM
Hello,
Python newbie alert!
I would appreciate a helping hand to get my first py script working.
The goal is to write a script that uploads a file to an sftp site after verifying the host ed25519 fingerprint.
I think the issue is that my keydata is not being decoded successfully?...?
I am unfamiliar with ed25519 keys but the key length i got from FileZilla is 44 characters. I tried to research on what the normal Ed25519 length is and found another source saying they should be 43 chars. So i removed the trailing = but that gave the error saying
..., line 546, in decodingbytes
return binascii.a2b_base64(s)
binascii.Error: Incorrect Padding
if a leave the trailing = i get the following error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 0: invalid start byte
My code below - based from here - https://stackoverflow.com/questions/4681...ingerprint
Python newbie alert!
I would appreciate a helping hand to get my first py script working.
The goal is to write a script that uploads a file to an sftp site after verifying the host ed25519 fingerprint.
I think the issue is that my keydata is not being decoded successfully?...?
I am unfamiliar with ed25519 keys but the key length i got from FileZilla is 44 characters. I tried to research on what the normal Ed25519 length is and found another source saying they should be 43 chars. So i removed the trailing = but that gave the error saying
..., line 546, in decodingbytes
return binascii.a2b_base64(s)
binascii.Error: Incorrect Padding
if a leave the trailing = i get the following error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 0: invalid start byte
My code below - based from here - https://stackoverflow.com/questions/4681...ingerprint
import pysftp import sys import paramiko from paramiko.py3compat import decodebytes path = './folder/' + sys.argv[1] #hard-coded localpath = sys.argv[1] host = "1.2.3.4" #hard-coded password = "passwd" #hard-coded username = "user" #hard-coded keydata = b"""RLh...kP+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)) 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")Would really appreciate any help on this