How to get the sha512sum of a latest file located on a remote machine using python

94 views Asked by At

I am trying to build a python wrapper which basically login to a remote machine and search for a latest file in a particular directory and return the sha512sum of that file so that I can compare the sha512sum with the file which i have in my local machine. I m trying to simulate the same using paramiko and execute_command method but didn't get the valid output , need some more pointers !!

Code snippet :

import paramiko
import subprocess
s = paramiko.SSHClient() 
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect("10.11.10.15",22,username="root",password='root123',timeout=4)
sftp = s.open_sftp()
stdin, stdout, stderr = s.exec_command('cd /home/test/; sha512sum default_ephemeris.csv')
for line in stdout:
print("shasum is :",line.strip('\n'))
0

There are 0 answers