1

I have a new Ubuntu 18 server in Azure. I am using PowerShell (with the 2018 SSH client already installed). I have tried Putty also. Both with PowerShell and Putty I typed in ssh username@ipaddress, type yes to accept and then I get Permission denied (publickey).

My Azure settings: no password required to log in, just Pub/Priv keys. I let Azure create the Keys so that must be done and stored correctly.

I think the issue is that I am not associating the private key, which is stored on my Windows 10 machine, properly. To be honest, I never tried to associate it. I don't know how to. Am I supposed to be in the directory where the key is when using PowerShell? I was never prompted for the private key anywhere.

2
  • The private key that azure created is stored on your local machine in the "C:\Users\<username>\.ssh directory yes?
    – Drifter104
    Dec 31 '20 at 11:20
  • It was not at first but during my research and troubleshooting, I thought that the system might look there as a default location so I moved the key to that directory. It didn't help though. Jan 1 at 15:29
1

When you creating new VM with generate key pair option, it should be downloaded on your drive (by default on Download folder). Then you need to insert privatekey.pem when connecting over ssh by adding -i attribute :

ssh -i keypair.pem azureuser@x.x.x.x
#or
ssh -i C:\pathtofolder\keypair.pem azureuser@x.x.x.x

But if you forgot or lost your keypair from azure. you can create new one using puttygen. Complete guide you can see in https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/

  1. Download and open puttygen. click generate and move your mouse randomly on the blank area until finish
  2. Save Private key on your machine, and copy public key
  3. go to azure, choose your VM. in left menu, choose Reset password and use public key option. then paste your public key Reset Password / SSH public key

4. it will create new user or updating the existing one 5. Double-click previously saved private key from puttygen, it will run as background service 6. Now you can ssh without adding -i attribute

0

Assuming your public key is sitting on the server, try

ssh -vvv username@ipaddress

to have more details about why permission is denided.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.