I am trying to create linux VM with azure cli from local machine. I was able to create VM using following command but now when I want to ssh into the VM, I need to have public key on my local machine?
How can I get the required public key to connect to vm using ssh azureuser@publicIpAddress
? Where are the ssh keys generated by --generate-ssh-keys
and how to get it?
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
I used PowerShell 7.0 with elevated privileges to run the above command
Solved
Update 1:
- SSH keys are generated in c:\users\.ssh\ when you use
--generate-ssh-keys
switch - If there are already file with name
id_rsa
&id_rsa.pub
then it might be conflicting and you can use another switch--ssh-key-values /path/to/public/key
to specify different file name - After that if you get
Permissions for 'private-key' are too open
error then follow steps mentioned here
~/.ssh
directory. Generate keys automatically during deployment