How To Create a Linux Virtual Machine in Microsoft Azure - SSH Authentication
Published: 2024-04-10 21:58:52

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzjvmfsg66llyni4upxr.png)

__Click on the "Create" button.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjl2ep8jhpgdmri7ni79.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qqtygxnf42170lym2g0a.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6sjq4d33jkftpno5zl3.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bta1hqxfp82drfakn7sw.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eu46zwhrieyzabccmmhy.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kx0kkdxmzbkq5oi6k9cf.PNG)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3d489fscuavz9rn1wtj.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3p2fkkw6eehx8lvam51.png)

_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4lsya1vb5riqk1n7blxd.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5i2gi8e6lxen83fb59w.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qo9zupbxw7axdkb9w53p.png)

__Your Azure VM should be running.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6mtlr3amkrab9jumef1.png)

__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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3l22ci3dybzwswhutr0x.png)

_Enter "yes" and press enter.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhaobl03xstgyv3wvtn7.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96za7a4kedjpwhnw33i9.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywx4ljn9fkv5ogvow0fo.png)