How to reset SSH key pair of Azure VM | How to use a new ssh key to connect with VM?

How to get a second copy of ssh keys, is there a way to reset SSH key to connect with linux VM, can we use a different SSH key to connect with VM, can we generate a new SSH key after losing the previous access key?

You can get access in an Azure VM if you have lost your access of that VM or you just created a VM and don't have credentials to login into the VM, in all these scenarios you can follow below solution.

1- Get the SSH key which you use to login in any other server.

OR

2- Create a new SSH key from SSH key service.

3- Copy the public key of the key file and paste in the field of below screenshot

4- Go to the VM and in left sidebar you will see an option Reset Password click on it.

To understand it in more details watch the below video:

 

More references:

https://learn.microsoft.com/en-us/azure/virtual-machines/ssh-keys-portal

https://learn.microsoft.com/en-us/answers/questions/222603/how-to-get-a-second-copy-of-ssh-keys.html