Skip to main content

Command Palette

Search for a command to run...

How I Created and Connected to a Linux VM on Azure—A Friendly Step-by-Step Guide

Published
7 min read
How I Created and Connected to a Linux VM on Azure—A Friendly Step-by-Step Guide

Have you ever wondered how cloud servers actually work?

In this article, I’ll guide you through the process of creating a Linux Virtual Machine (VM) in Microsoft Azure, connecting to it, and understanding its significance in real-world cloud computing.

This guide is perfect for those new to Azure and eager for hands-on experience.

By following along, you'll enhance your cloud computing skills, boost your confidence in managing virtual environments, and gain practical knowledge to advance your career, improve technical expertise, or satisfy your curiosity about cloud technology.

Let’s dive in!

What Is a Virtual Machine (VM)?

A virtual machine is like a computer inside the cloud. It runs an operating system, like Windows or Linux, and you can use it just like a real server. Azure lets you create these with just a few clicks and configure them to run apps, websites, or tests without paying for physical hardware.

Azure offers Linux VMs (like Ubuntu) that you can deploy easily via the Azure Portal.

Now, let’s go through the steps.

Step 1: Sign in to the Azure Portal

  1. Go to https://portal.azure.com

  2. Sign in with your Microsoft Azure account (create one if you don’t have one yet — there’s a free tier you can use)

Once you’re in, you’ll see the Azure dashboard as your cloud control center.

The Microsoft Azure Portal

Step 2: Create a New Virtual Machine

  1. In the Azure Portal search bar, type Virtual Machines

  2. Click Virtual Machines

  3. Click + Create

  4. Select Azure Virtual Machine

Step 3: Configure Basic VM Settings

On the Basics tab, fill in the following:

Project Details

  • Subscription: Free Trial (or your active subscription)

  • Resource Group:

    • Click Create new

    • Name it, example: Linux-VM-RG

    • Click OK

Instance Details

  • Virtual machine name: linux-vm

  • Region: Choose a region close to you (e.g., West US)

  • Availability options: No infrastructure redundancy required

  • Image: Ubuntu Server 20.04 LTS

  • Size:

    • Select a free-tier friendly option like:

      • Standard_B1s (if available)

Screenshot of the Microsoft Azure portal showing the "Create a virtual machine" page. Various fields are filled in, including subscription, resource group, virtual machine name, region, and image. Options like availability and security type are also visible.

Screenshot of the Microsoft Azure portal showing the "Create a Virtual Machine" page. Options include VM architecture selection between Arm64 and x64, Azure Spot discount, and VM size, with a selection of "Standard_D2s_v3 - 2 vcpus, 8 GiB memory ($70.08)." A notice about the free trial period is displayed. Buttons for "Next: Disks" and "Review + create" are at the bottom.

Set Administrator Account (Password Option)

Under the Authentication type, you have two options:

SSH Public Key

This is the more secure approach, and Azure can generate it for you automatically.

Password Authentication

If you choose a password instead, Azure will prompt you to enter a strong password. This is easier to remember but less secure than SSH keys — good for learning, but not best practice for production use.

Although the SSH public-key option is more secure than a password, in this article, I’ll be using password authentication

In the Administrator account section:

  • Authentication type: Password

  • Username: azureuser

  • Password: Create a strong password

    • Must be at least 12 characters

    • Include uppercase, lowercase, numbers, and special characters

Configure Inbound Port Rules

  • Public inbound ports: Allow selected ports

  • Inbound ports: SSH (22)

This allows remote login using the password.

Azure virtual machine configuration page showing fields for setting an administrator account using a password, with options for inbound port rules and SSH selected.

Step 4: Review and Deploy

  • Click Review + Create

  • Validation will pass

  • Click Create

  • Wait for the deployment to finish

Screenshot of the Microsoft Azure portal, displaying the "Create a virtual machine" interface. The "Review + create" tab is active, with a validation passed message. It lists VM details including the price of 0.0960 USD per hour for a Standard D2s v3 machine. Terms of service and privacy policy links are visible. Options for previous, next, and create are at the bottom.

Screenshot of a Microsoft Azure portal showing a deployment in progress for "CreateVm-canonical.ubuntu-24_04-lts-server." It lists deployment details, with various resources having a status of "Created" or "OK." The interface has options for cancellation, redeployment, download, and refresh.

Screenshot of the Microsoft Azure interface showing a completed deployment for an Ubuntu virtual machine. It includes deployment details, next steps, and offers options for cost management and security via Microsoft Defender for Cloud.

STEP 5: Connect to the Linux Virtual Machine

After the deployment was completed, I selected Go to resource to open the virtual machine’s overview page.

From the top menu on the virtual machine overview page, I selected Connect. Azure presented two connection options:

  • Connect

  • Connect via Bastion

Selecting the Connect Option

I selected Connect rather than Connect via Bastion.

The Connect option allows access to the virtual machine using SSH from a local terminal, while Azure Bastion provides browser-based access through the Azure Portal. Since I was connecting from my local machine, I proceeded with the Connect option.

Screenshot of the Microsoft Azure portal showing the overview page for a virtual machine named "B-linux-Vm" running Ubuntu 24.04. It displays details like resource group, status, location, operating system, size, and network configurations. A "Connect" dropdown menu is open with options to connect normally or via Bastion.

STEP 6: Connecting Using Command Prompt (Password Authentication)

After selecting Connect, Azure displayed the SSH connection details required to access the Linux virtual machine.

I copied the SSH command provided by Azure, which included the administrator username and the virtual machine’s public IP address..

This image shows a Microsoft Azure virtual machine connection interface. It includes SSH connection details, such as source machine information, destination VM IP and port, and SSH command for connecting. Options for checking access and resetting the password are also visible.

After copying the SSH command,

  • I searched for the command prompt in the system (for Windows users)

  • Then run as administrator

Screenshot of a Windows search for "cmd" showing the Command Prompt as the best match. Options displayed include "Open," "Run as administrator," "Open file location," "Pin to Start," and "Pin to taskbar." The left sidebar shows a Microsoft Azure interface with options like Overview, Activity log, and Connect.

I then opened Command Prompt on my device, pasted the command, and pressed Enter.

Command Prompt then prompted me to enter the administrator password configured during VM creation.

After entering the correct password, the SSH connection was established successfully, and I gained access to the Linux virtual machine.

A screenshot of a terminal window displaying a successful SSH login to an Ubuntu 24.04.3 LTS system. It includes system information such as load, memory usage, and IP address. There are no updates available, and a message about security maintenance not being enabled. It offers commands for checking updates and accessing additional security features.

This confirmed that the setup was complete, and I was ready to start using the VM for various tasks, such as deploying applications or running tests.

Conclusion

Creating and connecting to a Linux VM on Azure matters for real-world cloud computing because it provides a practical understanding of how cloud infrastructure operates. This experience is crucial for several reasons:

  1. Scalability: It demonstrates how resources can be scaled up or down based on demand, which is a key advantage of cloud computing.

  2. Cost-Efficiency: By using virtual machines, you can avoid the costs associated with maintaining physical hardware, paying only for the resources you use.

  3. Flexibility: It allows you to deploy and test applications in a controlled environment, making it easier to develop and iterate on software projects.

  4. Accessibility: Cloud-based VMs can be accessed from anywhere, facilitating remote work and collaboration.

  5. Security: Understanding how to configure and secure VMs helps in protecting data and applications in the cloud.

Overall, this hands-on experience is essential for leveraging the full potential of cloud computing in various real-world applications.