DEV Community

Cover image for How To Create a Linux Virtual Machine in Microsoft Azure - SSH Authentication

How To Create a Linux Virtual Machine in Microsoft Azure - SSH Authentication

Azure virtual machines (VMs) enable you to create dedicated compute resources in minutes that can be used just like a physical desktop, laptop or server machine.

A Linux virtual machine offers flexibility, convenience, and the ability to explore and test the Linux operating system without making permanent changes to your primary operating system or hardware.

The process of creating Azure resources such as a virtual machine using the Azure portal involves the following steps:

SIGN IN TO AZURE PORTAL
Initiate the create wizard.
Assign resource-specific settings.
Validate the assigned settings.
Initiate the resource.
SIGN IN TO AZURE PORTAL

As a prerequisite, you sign up to create a free account if you don't have an Azure subscription. once your Azure subscription is created, sign in to the Azure portal using your mail and password to get started.

After you're successfully authenticated, the Azure portal's home page displays. This page provides links to core services, recently accessed and favorite resources, built-in management tools, and online documentation. It also serves as a convenient entry point into your Azure environment.

If the functionality you're looking for isn't present on the home page, you can locate it by using either the portal menu or the global search textbox. Both options are available on every portal page to which you navigate.

Initiate the Virtual machine Create wizard

__In the search bar, type "Virtual Machine"

__From the search results, select "Virtual Machine" from the list of resources.

Image description

__Click on the "Create" button.

Image description

Assign resource-specific settings.
The settings you assign at this stage will determine the properties of the virtual machine. Although you can modify most of the settings after deployment, there are some settings that are immutable, (not changeable, once deployed or created).

The settings the Azure VM create wizard displays in the Azure portal are grouped into the following pages:

Basics
Disks
Networking
Management
Monitoring
Advanced
Tags

You are directed to the "Basics" page.

Project Details
In the project details category, there are subscription and resource group.

__Subscription

An Azure subscription in simple terms means a membership or access pass to use Microsoft Azure. It's similar to subscribing to a service or signing up for a subscription plan. paid, free and trial options are available.

__Resource Group

A resource group in Azure is a container or folder that helps you organize and manage the different resources such as virtual machines and databases that you use in the Azure cloud.

Image description

Instance Details

__Give your virtual machine a name.

__In the region section, select the location you want your virtual machine to be.

A region refers to a specific geographical location with data centers that host infrastructure and services. Each region operates independently and is designed to be self-contained, with its own set of resources and infrastructure.

__Next, click on the drop-down to select your availability option and availability Zone.

__In Azure, a region can consist of three availability zones, known as Zone 1, Zone 2 and Zone 3. Each zone has one or more data centers that are kilometers apart from each other.

Select your security type from the drop-down

_In the image section, select Ubuntu from the drop-down

__An image is an operating system. It's like a blueprint for creating virtual machines or computer systems. It has all the instructions and settings needed to set up a computer with a specific operating system and software.

Image description

__Select the size of your virtual machine from the drop-down or click on "See all sizes". Leave the other default information.

Image description

Administrator Account
__Select SSH Public key
__Enter the administrator's username for your virtual machine.
__Select Generate New Key Pair from the drop-down
__Leave the default given key pair name.

Image description

Inbound Port Rules

On the inbound port rules section, select "Allow selected ports" and then select SSH (22). This port will give you remote access to your physical work desktop computers.

Image description

Click on "Next: Disks>" to direct you to the Disk page.

Disk
__On the Disk page click on the OS disk type dropdown and select Standard SSD or any disk type of your choice as shown below. Leave the other columns as default.

__Leave the networking, management, monitoring and advanced pages as default. Skip to the Tag page.

Image description

Tag

__Give your tag a name.

Tags are a way to label and organize resources in cloud computing environments. The purpose of tags is to provide metadata or additional information that helps in managing, organizing, and tracking resources within a cloud infrastructure.

__Next, click on Review+create

At this point, the Azure portal will automatically invoke a validation task, which verifies that the options you've selected are valid. If you've misconfigured a setting or missed a required one, you'll have a chance to go back to the corresponding page to fix your mistake.

If validation is successful, select Create to initiate the deployment. Your Azure VM should be running shortly.

Image description

_When prompted, click on "Download private key and generate resource". This would generate a private key pair to your chosen folder in your local computer.

Image description

_Once the deployment is complete, click on "Go to resource".

Image description

Connect to Your Linux Virtual Machine.
__On the overview page of your virtual machine click "Connect".

Image description

__Your Azure VM should be running.

Image description

__Open PowerShell on your Laptop and input the command, Press enter key.

With the public key deployed on your Azure VM, and the private key on your local system, SSH into your VM using the IP address of your VM. In the following command;

ssh -i "C:\Users\DELL\Downloads\sangLinusKey_key.pem" sang@172.205.225.254

  • 1. - user name
  • 2. - key pair path
  • 3. - IP address

Image description

_Enter "yes" and press enter.

Image description

__If your connection did not time out/close, you would be logged in to your virtual machine as shown below.

Image description

__Input some Linux commands to test your new system as shown below:

Image description

Top comments (0)