This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.
A couple weeks ago I wrote about how I leveraged PowerShell SecretManagement to generalize a demo environment. In that article I only talked about Windows virtual machines running in Azure. However, my colleague Thomas Maurer revisited the topic in his article, Stop typing PowerShell credentials in demos using PowerShell SecretManagement. Thomas really concentrated on how the local Secret Store can help when you have demos of local scripts that need secrets, versus my article that concentrated more on how the SecretManagement module paired with the Az.KeyVault module can help manage not only demo environment but help manage local accounts across production environments.
In response to both these articles we got a lot of questions, so I decided to address one of them here.
Will it work for linux?
Absolutely, you can have PowerShell on Linux, and import the modules mentioned in the articles.
One of the differences that in most case we use SSH keys to access a VM running in Azure. And Azure has a couple ways of securely storing that information. When creating a VM you can generate one at deployment, upload your own, or use an existing one already in azure.
When using “Use existing one stored in Azure” it refers to a separate repo in azure different than Azure Key Vault. It actually saves the key in a portal service SSK Keys.
The SSH Keys portal service give you the ability to download the public key so you can connect to the appropriate VMs.
In one of the production environment that I’m currently involved with. We do not allow public IP assigned to VMs without a proper business case. I actually agree with this policy since it limits the number of attack vectors. So, we use Azure Bastion. Connecting using Azure Bastion offers the possibility to use one of several ways to authenticate to the VMs.
- SSH Private Key
- SSH Private Key from Local File
- SSH Private Key from Azure Key Vault
Using Azure Key Vault to securely store your keys and secrets allows you to manage the SSH keys by setting expiration dates, apply proper versioning, assign tags AND have them available to the Azure Bastion with the option of requesting the Passphrase.
Just like my previous article. In order to manage these keys, you can schedule an Azure Automation task, or an Azure Function to monitor the expiration dates and renew\regenerate the SSH Keys for you when appropriate. As a proof-of-concept I used the same Azure Automation Account as my last article with a new runbook to create the SSH keys for my environment and store them in Azure Key Vault
Please note that this runbook uses the New-RSAKeyPair cmdlet from the PEMEncrypt module imported in my Automantion environment from the PowerShell Galery.
Now, again this is a proof-of-concept piece of code. For production use a lot of changes would be required (not an exhaustive list)
- Expiration dates you be set.
- A function to validate that the afore mentioned expiration is not imminent.
- A function to update the key on each Linux VM in a set environment.
So, in conclusion, yes, you can use these new module on a Linux VM of you can use these new modules to help you manage the access to these Linux VMs.
I hope this helps.