DEV Community

Cover image for Deploying Your First Linux VM on Azure: A Step-by-Step Guide with SSH Key Authentication
Kolarinde Awopetutimileyin
Kolarinde Awopetutimileyin

Posted on

Deploying Your First Linux VM on Azure: A Step-by-Step Guide with SSH Key Authentication

Introduction
This guide walks you through creating an Ubuntu Linux virtual machine on Microsoft Azure using SSH public key authentication for secure access. Perfect for beginners looking to get started with cloud computing!

Step 1: Configure Your Virtual Machine Basics
VM Configuration


On the "Create a virtual machine" page, configure the following settings:

Size: Select Standard_E2s_v3 - 2 vcpus, 16 GiB memory from the dropdown menu. This provides adequate resources for most development and testing scenarios.
Administrator Account:

Choose SSH public key as your authentication type (more secure than password authentication)
Enter your desired Username: azureuser (or any username you prefer)
SSH public key source: Select "Generate new key pair"
Key pair name: Enter azureuser (this should match your username for consistency)

Inbound Port Rules:

Select Allow selected ports
Choose SSH (22) from the dropdown to enable remote access

⚠️ Security Note: Opening SSH to all IP addresses is only recommended for testing. For production, restrict access to specific IP addresses.
Click Next: Disks > then proceed to Review + create.

Step 2: Review and Create Your VM
Review + Create


On this page, you'll see:

A validation confirmation: "✓ Validation passed"
Your VM configuration summary including:

Virtual machine name: newkolalinux-vm
Resource group: Newkolalinux-rg
Region: West US
Pricing: 0.1480 USD/hr

Review all settings carefully, then click the blue Create button at the bottom.

Step 3: Download Your SSH Private Key
Deployment in Progress
Once deployment begins:

The status will show "⏳ Deployment is in progress"
IMPORTANT: A download prompt will appear for your SSH private key (the .pem file)
Download and save this key immediately - you cannot retrieve it later!
Store it securely in your Downloads folder or a dedicated SSH keys directory

The deployment details show three resources being created:

Network interface
Network security group
Public IP address

Step 4: Wait for Deployment Completion
Deployment Complete
When deployment finishes, you'll see:

"✓ Your deployment is complete."
Resource group: Newkolalinux-rg
Virtual machine name: newkolalinux-vm

The Next Steps section shows recommended actions:

Setup auto-shutdown
Monitor VM health and performance
Run a script inside the virtual machine

Click the Go to resource button to access your VM.

Step 5: Access Your VM Overview
VM Overview Page


On your VM's overview page, you'll find essential information:
Key Details:

Status: Running ✓
Operating system: Linux (ubuntu 24.04)
Size: Standard_E2s_v3
Public IP address: 20.237.186.3 ← You'll need this for SSH connection
Private IP address: 172.16.0.4
Virtual network/subnet: vnet-westus/snet-westus-1
DNS name: Not configured
Location: West US

The top menu bar shows options including Connect, Start, Restart, Stop, and more.

Step 6: Initiate SSH Connection
Connect Page
Click the Connect button from the top menu, then select the Connect option from the left sidebar.
You'll see the Native SSH connection method with:

SSH command displayed: ssh -i azureuser@20.237.186.3
A warning: "⚠️ Private key file path missing - Edit settings"

Note the copy icon next to the SSH command for easy copying.

Step 7: Configure SSH Private Key Path
Edit SSH Settings
Click Edit settings to open the Native SSH configuration panel.
In the side panel, you'll see:

Source machine: Windows, Local IP: 102.219.153.117
Destination VM: Public IP: 20.237.186.3, Port: 22
Connection prerequisites: Check inbound NSG rules ✓

SSH command section:

Locate the field: "Provide a path to your SSH private key file on your local machine"
Paste the full path to your downloaded .pem file
Example: C:\Users\HomePC\Downloads\azureuser.pem

Important Note: "Can't find your private key? Reset your SSH private key"
After pasting the path, click Save changes.

Step 8: Locate Your Private Key File

  • Windows File Explorer


Navigate to your Downloads folder in Windows File Explorer:

Path: This PC > Local Disk (C:) > Users > HomePC > Downloads
Locate the file: azureuser.pem (PEM File, 3 KB)
Right-click on the file
Select Copy as path to copy the full file path with proper formatting

This path is what you'll paste into the Azure portal SSH settings.

Step 9: Connect via Command Prompt
SSH Connection Command
Open Command Prompt on your Windows machine and paste the complete SSH command:


cmdssh -i "C:\Users\HomePC\Downloads\azureuser.pem" azureuser@20.237.186.3
Command Breakdown:

ssh: The SSH client command
-i "C:\Users\HomePC\Downloads\azureuser.pem": Specifies your private key file
azureuser@20.237.186.3: Your username and VM's public IP address

Press Enter to establish the connection.
First-time connection: You may see a prompt asking to verify the host's authenticity - type yes to continue.

Top comments (0)