Reputation: 117
I have followed below steps to generate pfx file and uploaded to azure keyvault, I am unable reference authorized_key
from pfx file using terraform into my linux box while creating, am I doing something wrong way ?
> openssl genrsa -out private.pem 2048
> openssl req -sha256 -new -key private.pem -out csr.pem
> openssl x509 -req -sha256 -days 365 -in csr.pem -signkey private.pem -out certificate.pem
> openssl pkcs12 -export -inkey private.pem -in certificate.pem -out certificate.pfx
Upvotes: 0
Views: 855
Reputation: 117
Since I don't find anything which can use a pfx certificate as SSH key, I tried and create a private key using OpelSSL and generate authorized_key using PuttyGen and created Azure KeyVault Secrets and then reference the public key into linux SSH_Key Data. while the private key is use to access through bastion.
Generate a private key using OpenSSL. (will use as Bastion host ssh private key from keyvault)
> openssl genrsa -out private.pem 2048
Open PuttyGen to Generate,
Authorized_Key (will be place in Linux box while creating., .ssh/authorized_keys)
data "azurerm_key_vault_secret" "example" {
name = "my-public-key"
key_vault_id = data.azurerm_key_vault.existing.id
}
module "testlinux" {
source = "../../modules/linux"
resource_group_name = azurerm_resource_group.main.name
vm_hostname = "vm-linux-01"
nb_instances = 1
nb_public_ip = 0
remote_port = "22"
admin_username = var.admin_username
vm_os_publisher = "OpenLogic"
vm_os_offer = "CentOS"
vm_os_sku = "7.5"
vm_size = "Standard_D2as_v4"
ssh_key = data.azurerm_key_vault_secret.example.value
vnet_subnet_id = data.azurerm_subnet.my-subnet-01.id
tags = var.tags
}
Upvotes: 0