How to use Azure Keyvault private key to connect to SFTP

Anonymous
2023-07-25T20:30:52.9566667+00:00

Hi,

I may be missing something but cannot understand how to use the private key stored in my Keyvault to access the desired SFTP server, via an azure function.

Using the code examples here - https://www.alessandromoura.com.br/2022/02/14/connecting-an-azure-function-to-a-sftp-server-using-ssh-keys-stored-in-azure-key-vault/ - I have tried to connect. I appear to acquire the key no problem but Im assuming its the public version as the only thing that works on it is:

            var Kclient = new KeyClient(new Uri(KVault), new DefaultAzureCredential());

            KeyVaultKey key = Kclient.GetKey("mykey");

            MemoryStream ms = new MemoryStream(key.Key.ToRSA().ExportRSAPublicKey());

After this when I try to connect it just gives me "Invalid private key file". What am I doing wrong?

Have i configured this correctly? When using keys to access SFTP, is it correct to store them in the Keyvault this way?

Thanks for your time.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 15,256 Reputation points MVP Volunteer Moderator
    2023-07-29T16:15:39.8066667+00:00

    Hello @Rene Docherty

    There is no ability to transfer parameters from Key Vault Connector or HTTP queries to the "sftp connection" as a password parameter.

    how to pass the parameters file's reference to the key vault.

    If the Answer is helpful, please click `Accept Answer` and **up-vote**, so that it can help others in the community looking for help on similar topics.
    
    0 comments No comments

  2. SUNOJ KUMAR YELURU 15,256 Reputation points MVP Volunteer Moderator
    2023-07-29T16:16:10.1466667+00:00

    Hello @Rene Docherty

    There is no ability to transfer parameters from Key Vault Connector or HTTP queries to the "sftp connection" as a password parameter.

    how to pass the parameters file's reference to the key vault.

    If the Answer is helpful, please click `Accept Answer` and **up-vote**, so that it can help others in the community looking for help on similar topics.
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.