Search code examples
azureazure-resource-managerssh-keys

How to generate a keypair of a existing SSH key using azure ARM or sdk Java code


I have created an SSHKey on the azure cloud using below ARM template (Ref: link)

{
    "location": "eastus",
    "name": "sshkeyname",
    "type": "Microsoft.Compute/sshPublicKeys",
    "apiVersion": "2019-12-01",
    "properties": {}
}

After successful deployment I can see that ssh key is created on azure cloud, but don't have public key. Now I want to generate the public key for this key. I know using ssh-keygen command I can generate it, but I want to know is there any possibility to generate using ARM template. Please help. Thanks in advance.


Solution

  • Unfortunately, it's impossible to generate the SSH public key if you do not provide it. When you create the SSH key pair in the Azure portal, then you can see the ssh key pair like this:

    enter image description here

    Azure generates the public key for you to set as the value of publicKey. But inARM template, you need to provide it yourself.