A Guide to Revoking and Reconfiguring SSH Keys on Azure VMs

less than 1 minute read

Prerequisites

  • Azure CLI installed

Generate public and private key for new administrator

![](/assets/images/Azure/SSH/1-SSH.png)  
![](/assets/images/Azure/SSH/2-SSH.png)  

Create an administrative/sudo user or revoke exsiting one

In Azure CLI, login to your account then setup subscription that is hosting VM, and run Azure CLI command with those options:

  • –resource-group - Name of resource group that is hosting Virtula Machine.
  • –name - name of Virtula Machnine
  • –username - new administrator account name or existing one.
  • –ssh-key-value - path to your saved public SSH key. ``` az login az account set –subscription “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” az vm user update –resource-group rg-admin-001 –name vm-linuxadmin –username revokeadmin –ssh-key-value “C:\Temp\SSH\azure-admin-vm-public-key.pub”

```

Connect to Virtula Machine using new account and SSH key (PuttY example)

  1. Start PuTTY
  2. Enter IP address of Virtual Machnine

  1. On menu naviagate to Connection –> Data and enter admini login

  2. On menu naviagate to Connection –> SSH –> Auth –> Credentials and load Private key located on the local storage.

  3. Connect to VM with new sudo administrator account.

Leave a comment