-1

I created a VM using "use existing public key". When I try logging into Linux Server using SSH, I'm getting error as "Permission denied (publickey)". In case if I select "use existing key stored in Azure", it is working as expected.

Can you please suggest why I'm getting this error.

Regards, Santosh

  • Please check this it may help you :https://linuxhint.com/ssh-permission-denied-publickey-error/ – RahulKumarShaw Mar 10 '22 at 12:30
  • 1
    @RahulKumarShaw-MT, I'm not able to login into Server as it is blocking as "publickey permission denied". Steps to replicate the issue 1. Create a public key in Azure portal 2. Copy the public key 3. while creating VM, select SSH public key source as "use existing public key" and paste the copied one from step 2 and create VM 4. run SSH command, we can see the public key permission denied error – user2160698 Mar 11 '22 at 06:07
  • Thank you for the providing the steps . Will try to reproduce in our environment and will get back to you. – RahulKumarShaw Mar 11 '22 at 06:48
  • This is not a [programming question](https://stackoverflow.com/help/on-topic). – Martin Prikryl Mar 16 '22 at 13:09

1 Answers1

-1

You can not use the public key created in Azure as Use Existing Public Key. Public Key Created in Azure in only for User existing key stored in Azure.

For using the Use Existing Public Key You need to create a Public Key in your local machine or you can create using azureCLI as well.

The following command creates an SSH key pair using RSA encryption and a bit length of 4096:

ssh-keygen -m PEM -t rsa -b 4096

enter image description here

Using the above command you will have two key one is private(id_rsa) and another is public(id_rsa.pub).Use the Public One you can get the key at this location cd /home/rahul/.ssh/

Refere this Microsoft Document.

RahulKumarShaw
  • 4,192
  • 2
  • 5
  • 11
  • We can use existing key generated by Azure. Issue was invalid public key was used due to which this issue occured. – user2160698 Mar 14 '22 at 14:59