Key Vaults Secrets and RSA Keys

Gary Longford 21 Reputation points
2021-12-17T13:39:47.147+00:00

Hi,

I am trying to store a RSA key in the ADF Key Vaults so it can be use with a Linked Service.

However whenever I try to test SFTP connection it comes back with this error:

ErrorCode=SftpInvalidSftpCredential,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Invalid Sftp credential provided for 'SshPublicKey' authentication type.,Source=Microsoft.DataTransfer.ClientLibrary.SftpConnector,''Type=System.FormatException,Message=The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. ,Source=mscorlib,'

How do store RSA keys as a secret?

Regards

Gary Longford

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,118 questions
{count} votes

Accepted answer
  1. Andriy Bilous 10,901 Reputation points MVP
    2021-12-17T15:23:48.787+00:00

    Hello @Gary Longford

    I understand that you are trying to upload your RSA key to Azure Key Vault so it could be used in Azure Data Factory and you are getting an error while testing the connection:
    158651-image.png

    When you are trying to upload the RSA key, the web browser experience to copy the key within a secret. By doing this, the format of the string changes from Base-64 encoding to string.
    Try to upload the RSA key using PowerShell:

    #Upload RSA key  
    $PrivateKey = [System.IO.File]::ReadAllBytes("C:\Your file")   
      
    # Convert to base 64 and to secure string   
      
    $Base64 = [System.Convert]::ToBase64String($PrivateKey)   
    $Secret = ConvertTo-SecureString -String $Base64 -AsPlainText -Force   
      
      
    # Upload key to Azure Key Vault secret    
    Set-AzureKeyVaultSecret -VaultName 'KeyVault-Name' -Name 'SecretName' -SecretValue $Secret     
    

    https://www.techtalkcorner.com/upload-ssh-key-azure-key-vault/


0 additional answers

Sort by: Most helpful