How to SSH into Azure VM

Follow the below quick steps to SSH into Azure VM.

  1. Log in to Azure Portal.
  2. Search for Virtual Machines and click on the Search result Virtual Machines as shown below.
how to ssh into azure linux vm

3. Click on the Azure virtual machine option from the + Create dropdown.

ssh into azure linux vm

4. Provide the details as shown in the screenshot below.

connect to azure vm using ssh key
how to ssh into ubuntu azure vm
connect to linux vm from windows using ssh

Ensure to provide the below details.

  • Image: Choose the required Ubuntu server version.
  • Authentication Type: Select the SSH Public Key option.
  • User name: Provide a user name, or you can keep the default value as it is.
  • SSH public key source: Select the Generate new key pair option.
  • Key Pair name: Enter the name for the key pair or you can also keep the default option as it is.
  • Public inbound Ports: Choose the allow selected ports option.
  • Select inbound ports: Select the SSH (22) option.

Click on the Review + Create button.

5. Click on the Create button on the next screen.

6. Ensure to click on the Download private key and create resource button, as shown below.

connect to vm using ssh key

Now the PEM file has been downloaded like below.

how to connect to azure vm using ssh key

The resource was created successfully. Click on the Go to Resource button.

connect to azure vm using ssh

7. On the Azure Virtual Machine page, click on the Connect option from the left navigation. You will find two options to connect via SSH.

  • Native SSH
  • SSH using Azure CLI.

Let’s discuss the Native SSH approach, where we need the private key that we downloaded earlier. Click on the Select button to see the complete instructions.

connect to linux vm from windows using ssh key

8. Read the instructions in the Native SSH windows screen and then click on the Copy button to copy the command.

ssh into azure vm

The copied command looks like below

ssh -i ~/.ssh/id_rsa.pem azureuser@

After the modification, the command looks like below. Make sure to change the .pem file path that we have downloaded above as per yours.

ssh -i C:\Users\mail4\Downloads\AzureVM_key.pem azureuser@

9. Now open the command prompt, paste the above command, and press Enter. As you can see in the screenshot below, we are able to connect to the VM successfully with the SSH key.

azure ssh key

10. Sameway, For SSH using the Azure CLI option, click on the Select button as shown in the screenshot mentioned in step 7.

connect to vm using ssh azure

Video Tutorial

You may also like following the articles below