Reset SSH Key On Azure Linux VM

One of the ways of authenticating with a remote system is to use SSH keys. This tool was created to authenticate with a remote server without having to type in a password, but also allow for two-factor authentication and not sending the password in the clear over the network.

You can use ssh-keygen to generate an SSH key and then add it to your private key on your local machine. It’s essential to make sure that your public key is added to the authorized_keys file on your remote server. If both files are out of sync, it won’t work.

Reset SSH Key Azure

To reset an SSK on a Linux virtual machine hosted on Azure, we need to use the Reset password option available under the Support + Troubleshooting section of the VM configuration side menu.

From the Reset password page, select Reset SSH public key.

Run the following command from your local machine (macOS, Linux or WSL) to create a new SSH key (you can use the existing one if you like).

The command will ask you for details about the key (path and name).


Once the new SSH has been generated, copy the public key (the name ends with .pem), and you can use the cat command.

cat sshkey.pem

Back in the Azure portal, type the username the key belongs to and paste the public key.

Wait a few minutes and log in.