How to reset password in Azure virtual machine

How to reset password in Azure virtual machine

In this Azure tutorial, we will discuss the Azure virtual machine reset password. Apart from this, we will also discuss the below topics:

  • Azure virtual machine reset password using PowerShell
  • Azure Virtual Machine Reset Password Using Azure CLI
  • Azure virtual machine reset configuration using PowerShell
  • Reset Azure VM Password PowerShell
  • How To Find Azure VM Username And Password
  • Azure VM Password Reset Not Working

How to reset password in Azure virtual machine

Let’s discuss how can we reset the password of the virtual machine in the Azure portal.

You can follow the below steps to reset the password for the virtual machine

Step- 1: 

Login to https://portal.azure.com/

Step- 2: 

Search for Virtual machines there.

Azure virtual machine reset password

Step- 3: 

 You will see the list of VM created in your Azure subscription. It will show the VM name, Type, Status, ResourceGroup, Location, etc.

How do I reset my Azure VM password?

Step- 4: 

Now click on the VM name. “MyNewVM” in my case. You can able to see the details of your virtual machine like Public IP address, status, Computer name, Operating system, Size, etc.

How to reset the password of the Azure virtual machine

Step- 5:

From the left side menu select the Reset password option under support + troubleshooting.

azure reset linux vm password

Step- 6:

If you will see in the below screen the Reset password option is disabled and it is saying “The virtual machine must be running before using VMAccess

How to reset the password of the Azure virtual machine

This is because maybe my VM status is Stopped (deallocated) or not running. Let’s check that.

You can see below the VM status is Stopped (deallocated). Now click on the start button then after the VM status will be Running.

How to reset the password of the Azure virtual machine

Step- 7:

Now if you will click on the Reset password option again. You can able to see the Reset Password option is enabled.

Choose the Mode as Reset password.

Enter the username, password and confirm the password and then click on the Update button.

Reset Azure VM Password PowerShell

This is how you can reset your VM password from the Azure portal.

Azure virtual machine reset password using PowerShell

Well, let’s discuss here, How to reset Azure VM password using PowerShell.

Step- 1:

First, connect to the Azure account using the below command.

Connect-AzAccount 

Step- 2:

Select the Azure subscription ID

$MySubID = "<Mention Your Subscription ID>"
Select-AzSubscription -SubscriptionId $MySubID 

Step- 3:

Set the Set-AzVMAccessExtension to reset the username or password.

$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Now below is the complete Powershell script

$MySubID = "<Mention Your Subscription ID>"
$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Connect-AzAccount 
Select-AzSubscription -SubscriptionId $MySubID
Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Azure Virtual Machine Reset Password Using Azure CLI

Well, We have discussed above how to reset passwords for Azure VM using Azure Portal and PowerShell. Same way, you can also reset the password for your Azure Virtual machine using Azure CLI using the below quick steps.

  1. Open the Azure CLI from Azure Portal.
  2. Run the below cmdlt to reset or change the password using Azure CLI.
az vm user update
 -n {Your Virtual Machine name}
 -g {Name of your resource group}
-u {Your username}
 -p {Your password}

Example:

az vm user update
 -n TSINFOVM
 -g Demo12
-u User1 -p Password@12345

Azure virtual machine reset configuration

This step will reset the RDP configuration.

Step- 1: To do this, select your VM from the Azure portal, and from the left menu from the Support + troubleshooting section, select the “Reset password” button

Azure virtual machine reset configuration

Step- 2: Now the below window will open, select the mode as “Reset configuration only” and then click on the “Update” button.

azure reset linux vm password

Azure virtual machine reset configuration using PowerShell

You can use the below PowerShell script to reset the configuration of your virtual machine

$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$VMAccessname = "<Mention your VM access name>" 
$MyLocation = "<Mention your VM Location>"

Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -VMName $MyVmName -Name $VMAccessname -Location $MyLocation -typeHandlerVersion "2.0" -ForceRerun

How To Find Azure VM Username And Password

If you have missed your Azure virtual machine username and password, then no need to worry you can able to reset the username and password using the below steps:

Follow Step- 1 to Step-7 to reset the username and password from the “How to reset password in Azure virtual machine” section above.

Azure VM Password Reset Not Working

If you are facing any issues while resting the Azure Virtual Machine password or you are not able to reset the password for your Azure Virtual machine or once reset your password, you are not able to connect to your Virtual machine, then a few points you need to make sure as mentioned below.

  • Verify that the Network Security Group (NSG) is associated with your Azure Virtual Machine for port 3389. If not, then you can add the same by logging in to the Azure Portal –> Select the Virtual Machine –> Click on the Networking link. Add a new inbound rule.
  • Click on the Boot Diagnostics link from the left navigation to verify if the VM is booted properly.
Azure VM Password Reset Not Working

Change / Reset Password of Virtual machine (VM) – Video Tutorial

You may like the following Azure tutorials:

Conclusion

In this Azure tutorial, We discussed

  • How to reset password in Azure virtual machine
  • Azure virtual machine reset password using PowerShell
  • Azure Virtual Machine Reset Password Using Azure CLI
  • The Azure VM reset configuration
  • Azure virtual machine reset configuration using PowerShell
  • Reset Azure VM Password PowerShell
  • How To Find Azure VM Username And Password
  • Azure VM Password Reset Not Working

Hope you have enjoyed this article !!!