Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied (publickey) #37692

Closed
soheilade opened this issue Aug 23, 2019 · 9 comments
Closed

Permission denied (publickey) #37692

soheilade opened this issue Aug 23, 2019 · 9 comments

Comments

@soheilade
Copy link

soheilade commented Aug 23, 2019

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?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Alberto-Vega
Copy link
Contributor

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.

@Alberto-Vega
Copy link
Contributor

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.

@soheilade
Copy link
Author

soheilade commented Aug 25, 2019

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.

@jakaruna-MSFT
Copy link
Contributor

jakaruna-MSFT commented Aug 26, 2019

@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

@soheilade
Copy link
Author

soheilade commented Aug 26, 2019

@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.
image

another question is where in myVm should the public key be located? in the home directory?

@jakaruna-MSFT
Copy link
Contributor

@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.
image

Try this out and let me know.

@soheilade
Copy link
Author

@jakaruna-MSFT thanks, i needed to create a user. problem solved 👍

@dbshawt
Copy link

dbshawt commented Apr 22, 2021

hey, @soheilade what do you mean by creating a user?

@cynthn
Copy link
Contributor

cynthn commented Apr 22, 2021

@dbshawt In order to use the serial console you have to have a user account on the machine that is secured with a password (not an SSH key). I think that might be what they mean by creating an account - the original VM used an SSH key, so they needed to create a new acocunt with a password to use serial console.

But, someone can correct me if I am wrong :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants