I would like to pass my actual private-key value as argument instead of providing the file path.
I have used below code as of now:
import pysftp
import os
cnopts = pysftp.CnOpts()
if str(host_keys).lower() =='none':
cnopts.hostkeys = None
else:
cnopts.hostkeys.load(hostkeys)
filename = os.path.basename(localpath)
print(filename)
remotepath = os.path.join(remotefolder, filename)
print(remotepath)
with pysftp.Connection(host=hostname, port=int(port), username=username, password=password, cnopts=cnopts,private_key=private_key_filepath) as sftp:
sftp.put(localpath, remotepath=remotepath)
Please suggest some way to pass it as text.
Example:
private_key='abcdmyprivatekeytext'
In actual scenario I will be placing my private-key text in secure vault.