0

I'm using the @azure/keyvault-keys package to get the pem private key I uploaded to the Azure KeyVault. Now I would like to retrieve that and connect to SFTP like this

return this.sftpClient.connect({
  host,
  port,
  username,
  privateKey: secret.key,
});

Where private key is defined as

    /** Buffer or string that contains a private key for either key-based or hostbased user authentication (OpenSSH format). */
privateKey?: Buffer | string | undefined;

I'm however unable to figure out a way to get the keyvault uploaded PEM file as I would locally using

privateKey: fs.readFileSync('/path/id_dsa_key.pem'),

How can I utilize Azure Key Vault to store my private key and then connect to the SFTP client with this key vault key?

user3677331
  • 698
  • 2
  • 7
  • 22
  • Are you getting any errors? Did you link the managed identity or set the correct access policies on your keyvault? – Enrico Feb 24 '22 at 13:22
  • 1
    When a private key is held as a key in Key Vault, it cannot be exported in the clear. You could store it as a secret, however, and that would work. – MichaelHoward-MSFT Mar 20 '22 at 14:11
  • @MichaelHoward-MSFT that's what we eneded up doing. If you post this as an answer I'll accept the solution, thanks – user3677331 Sep 16 '22 at 13:16

0 Answers0