A Guide to Revoking and Reconfiguring SSH Keys on Azure VMs
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)
- Start PuTTY
- Enter IP address of Virtual Machnine
-
On menu naviagate to Connection –> Data and enter admini login
-
On menu naviagate to Connection –> SSH –> Auth –> Credentials and load Private key located on the local storage.
-
Connect to VM with new sudo administrator account.
Leave a comment