Forum Discussion
danielcregg
Feb 18, 2022Copper Contributor
Azure CLI create VM and assign it a password AND a ssh key for login?
How do I create a VM using Azure CLI and assign it a password AND a ssh key for login?
Here is the command I want to use but it just creates the ssh key and ignores creating the password.
az vm create --resource-group VMResourceGroup --name ubuntuVM --image Canonical:0001-com-ubuntu-server-impish:21_10-gen2:21.10.202202010 --size Standard_B1s --os-disk-size-gb 64 --public-ip-sku Basic --admin-username xman --admin-password 'mypassword*1'
Thanks
Regards
Daniel
- Based on the info in the docs, it looks like you need to set the auth type to all to allow both SSH & password:
--authentication-type
Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux. "all" enables both ssh and password authentication.
accepted values: all, password, ssh
- ezeeloginCopper Contributorgood stuff thanks for contribution
- Davy_ABrass ContributorBased on the info in the docs, it looks like you need to set the auth type to all to allow both SSH & password:
--authentication-type
Type of authentication to use with the VM. Defaults to password for Windows and SSH public key for Linux. "all" enables both ssh and password authentication.
accepted values: all, password, ssh- danielcreggCopper ContributorThanks, this works.
To create a free Ubuntu VM with password and ssh keys I create a resource group called myResourceGroup and I run the following command:
az vm create --resource-group myResourceGroup --name myVM --image Canonical:0001-com-ubuntu-server-impish:21_10-gen2:21.10.202202010 --size Standard_B1s --os-disk-size-gb 64 --public-ip-sku Basic --authentication-type all --generate-ssh-keys --admin-username azureuser --admin-password SoMePaSsWoRd1