Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
paramiko.ed25519key
#1
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
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
Reply


Messages In This Thread
paramiko.ed25519key - by cverm - Nov-30-2018, 08:31 PM
RE: paramiko.ed25519key - by nilamo - Nov-30-2018, 09:25 PM
RE: paramiko.ed25519key - by cverm - Dec-03-2018, 01:18 PM
RE: paramiko.ed25519key - by nilamo - Dec-03-2018, 05:11 PM
RE: paramiko.ed25519key - by cverm - Dec-06-2018, 01:04 PM
RE: paramiko.ed25519key - by nilamo - Dec-06-2018, 03:45 PM
RE: paramiko.ed25519key - by cverm - Dec-06-2018, 08:26 PM
RE: paramiko.ed25519key - by nilamo - Dec-06-2018, 08:39 PM
RE: paramiko.ed25519key - by cverm - Dec-07-2018, 11:47 AM
RE: paramiko.ed25519key - by nilamo - Dec-07-2018, 03:59 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020