I have an SFTP that I set up with *.PGP Files on that server. The package I use to connect to the SFTP from python is Paramiko as shown below.
import paramiko
transport = paramiko.Transport(json_data["host"], 22)
transport.connect(username=json_data["username"], password=json_data["password"])
sftp = paramiko.SFTPClient.from_transport(transport)
Also, I use pgpy for decrypting the message. Basically the key comes from a google cloud storage bucket and load it into the keychain and decrypt the file
I have set up this the decryption already for a local file but can't seem to figure out how to decrypt the message on the server.
I can't use the get function because I will be running this code on Google cloud functions, thus won't be able to access a local dir.
Is there any way I can load the file into Python, decrypt the file and then load it into a Pandas. The end file is a .CSV file.
The actual code used for decrypting local files.
import pgpy
key = pgpy.PGPKey().from_file("path/to/file/keyfile.asc")
with key[0].unlock("password") as ukey:
message = pgpy.PGPMessage().from_file("path/to/file/file.pgp")
f = ukey.decrypt(message).message
print(f)
This would decrypt the message locally.