Azure-cli: [VM Create]How to add multiple ssh keys while creating VM?

Created on 1 Mar 2019  路  6Comments  路  Source: Azure/azure-cli

Hi,

We wish to add multiple ssh keys while creating VM. For example, I wish to create a VM with user "azureuser" and add 2 public keys to it. The RestAPI(https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#create_a_vm_with_ssh_authentication.) can support this feature. Is this feature supported in Azure CLI? Thanks!

Compute-cli Workaround

Most helpful comment

@adewaleo, let us wait on this before we get more votes. When to fix it, we can expand the --ssh-key-value to be a list

All 6 comments

Not supported through vm create, and also after a vm gets create, the linuxConfiguration.ssh.publicKeys becomes read-only. Based on that, before we get more votes for the support, right now, your workaround is:

  1. az vm create --debug --validate" and get the template
  2. Add a new ssh entry into the template file
  3. Run az group deployment create <template-file>

@adewaleo, let us wait on this before we get more votes. When to fix it, we can expand the --ssh-key-value to be a list

@yugangw-msft, this might also be a good candidate for generic --set for create commands.

@yugangw-msft Thanks for the workaround and looking forward to the new feature support :)

@yuxisun1217, this feature has been added via #9306 with --ssh-key-values. --ssh-key-value would also work. They are aliases for one another, as the CLI accepts prefixes of options as long as it is unique to one option.

These change should be in our upcoming 5/21 release.

Got it. Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings