Azure Key Vaults, SSH Keys, and You

frederickollinger

Frederick Ollinger

Posted on August 8, 2022

Azure Key Vaults, SSH Keys, and You

A quick post of how to work with ssh keys using MS azure.

Making a key pair:

ssh-keygen -t rsa
Enter fullscreen mode Exit fullscreen mode

In this example, use the defaults. (Hit ENTER till the key is created.)

You should have a key in:

ls .ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode

Given an Azure Keyvault that you haver previously created, find that vault:

az keyvault list
Enter fullscreen mode Exit fullscreen mode

For this example, let's call it "mykeyvault".

Upload the key.

az keyvault secret set --name sshkey --vault-name mykeyvault --file ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode

List the keys:

az keyvault secret list --vault-name mykeyvault
Enter fullscreen mode Exit fullscreen mode

Now we can get the key:

az keyvault secret download --name sshkey --vault-name mykeyvault --file sshkey.pem
Enter fullscreen mode Exit fullscreen mode

This should create a file which is the same as ~/.ssh/id_rsa. Prove it with diff.

diff ~/.ssh/id_rsa sshkey.pem
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
frederickollinger
Frederick Ollinger

Posted on August 8, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related