How Do You Change a User’s Password When You Cannot Log into Your Azure Linux VM?

Problem scenario
You have a Linux VM in Azure but you cannot log in.  You cannot remember a single password for the username you were using.  What do you do when you forgot all the credentials of a Linux VM except one username?  How can you log into this server?

Solution
Prerequisite
To reset access to the VM in the following way, you will need to know one username. 

Procedures
1.  Open the Azure Cloud Shell by logging into the Azure Portal and clicking on the ">_" symbol in the upper right hand corner. 

2.  Run a version of this command where "changethis" is the name of the resource group of the VM, "nov16" is the name of the Azure VM, "azubuntu" is username that you want to change the password of (the username you remember), and "myNewPassword" is the password you want the user to now have:

az vm user update \
  --resource-group changethis \
  --name nov16 \
  --username azubuntu \
  --password myNewPassword

Leave a comment

Your email address will not be published.