I’m using Ansible Automation Platform 2.5 operator install on OpenShift. I want to be able to retrieve a private key stored in Azure Key Vault as a key to use as the private key for an ssh connection.
Is there a way to make this happen? All I can find is secret retrieval, and my attempts to store a key as a secret and retrieve into the SSH Private Key field of my Machine credential result in:
Error loading key “/runner/artifacts/2000/ssh_key_data”: invalid format
Password vi ssh with the same cred retrieved as a secret into the Password field works just fine.
I actually figured this out. Using the az command to upload the key as a secret put it in the correct format that Ansible could read.
az login
az keyvault secret set --vault-name “YourKeyVaultName” --name “YourSecretName” --file “~/path/to/id_rsa_private_key_file”
Once there, using a machine cred with the key button under SSH Private Key, I was able to specify the external vault and retrieve the private key as a secret that way, and it worked!