0

I'm tryng to generate a Hash according to SFTP connection.

Using module paramiko like the code below.My intention is to compare this Hash with de Hash that i'll have when decrypt the digital sign with the publicKey of the Host.

I'm based my logic according to paramiko documentation that we can see here:https://docs.paramiko.org/en/stable/api/sftp.html

So, like this, I created a an SFTPFile object representing the open file and trying to use "check" method.

I got the right archives but i need do verify the hash code.

Anyone else got the same problme or something like this?

Code:

#Transport
host = 'site'
port = 22
transport = paramiko.Transport((host, port))

#Connecting to the server
username = 'restrict'
password = 'restrict'
transport.connect(username = username, password = password)

#SFTP Client
sftp = paramiko.SFTPClient.from_transport(transport)

#Obtanaing archives
path = 'restrict'
localpath = 'restrict'
sftp.get(localpath, path)

#Lits oh archives 
dir_list = sftp.listdir()

#Created a file object to obtain hash
file_obj = sftp.file('itaucor67/BMF.xlsx', mode='r', bufsize=-1)

#Tring to obtain the Hash
file_obj.check('sha1', 0, 0, 1024)

file_obj.close()

sftp.close()
transport.close()
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

0 Answers0