I am trying to retrieve the contents of a ppk file from secrets manager and use it to connect to SFTP.
I can do it easily if I store the file locally and pass the file.
const sshConfig = { //This works
host: 'host',
port: 22,
username: 'username',
passphrase:'passphrase',
privateKey: fs.readFileSync(ppkFile.ppk),
readyTimeout: 99999,
};
If I try to pass the contents of the ppk file as stored in AWS SecretsManager it doesn't work.
const sshConfig = { //This doesn't work
host: 'host',
port: 22,
username: 'username',
passphrase:'passphrase',
privateKey: fs.readFileSync('file contents retrieved as a string from secretsmanager'),
readyTimeout: 99999,
};
I have also tried to convert the string returned from AWS SecretsManager into a buffer before instead of using fs.readFileSync but that didn't work.
const sshConfig = { //This doesn't work
host: 'host',
port: 22,
username: 'username',
passphrase:'passphrase',
privateKey: Buffer.from('file contents retrieved as a string from secretsmanager'),
readyTimeout: 99999,
};
Can this be done and if so can someone help me get it right?