after following these commands in azure:
az group create --name myResourceGroup --location westeurope
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
ssh azureuser@publicIpAddress
I get this error
Permission denied (publickey)
and i am not able to connect to VM. any idea where is the problem?
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hi @soheilade I'm sorry to hear that you are facing this issue. Could you please link the URL of the documentation you were following? That way, we can pass your feedback to the appropriate content author.
Hi @soheilade just a friendly reminder to share the link to the doc this feedback is for. If this is not related to any doc I will suggest you to please search and or post on the developer forums like StackOverflow where unlike here there is a community that can help.
Hi Alberto, here is the link to documentation I followed.
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json
please let me know how can I solve this permission problem. Thanks alot.
@soheilade in the cli command to create vm the flag --generate-ssh-keys is given.
Do it would have picked the public key in your home directory (/home/user/.ssh/id_rsa.pub) and uploaded it to the Azure virtual machine.
Then you can use the private key (~/.ssh/id_rsa) to login .
Make sure you have that file in your machine.
Please try with the below command which explicitly specifies which key to use.
ssh -i ~/.ssh/id_rsa azureuser@yourpublicip
Also the permissions of the id_rsa should be 400
-rw------- 1 user user 1679 Feb 18 2019 /home/user/.ssh/id_rsa
you can also go to the password option instead of ssh keys.
for specifying password us the flag --admin-password
@jakaruna-MSFT , thanks, but how do I move the public key to a VM that I cannot access to? The serial console of azure is not working either.

another question is where in myVm should the public key be located? in the home directory?
@soheilade
You need to enable boot diagnostics for the serial console.
That public key would have been placed in the VM automatically by the CLI.
You can find that on the ~/.ssh/authorized_keys file in the Azure virtual machine
If you are looking for a way to login to that VM, You can easily reset the password for your username or create a new user with username and password.
For resetting the password, Please go to the VM blade and search for "reset password"
Then provide the required details ans submit.

Try this out and let me know.
@jakaruna-MSFT thanks, i needed to create a user. problem solved 👍
Most helpful comment
@soheilade in the cli command to create vm the flag
--generate-ssh-keysis given.Do it would have picked the public key in your home directory (/home/user/.ssh/id_rsa.pub) and uploaded it to the Azure virtual machine.
Then you can use the private key (~/.ssh/id_rsa) to login .
Make sure you have that file in your machine.
Please try with the below command which explicitly specifies which key to use.
ssh -i ~/.ssh/id_rsa azureuser@yourpublicipAlso the permissions of the id_rsa should be 400
-rw------- 1 user user 1679 Feb 18 2019 /home/user/.ssh/id_rsayou can also go to the password option instead of ssh keys.
for specifying password us the flag
--admin-password