How to Deploy and Connect to Linus Virtual Machine in Azure: Step by Step Guide
Tags: cloudcomputing, azure, microsoft, tutorial
Published: 2024-06-21 03:50:43

Table of Contents <a name="contents"></a>
[Create (Deploy) Linus Virtual Machine] (#create)
[Connect to Linus Virtual Machine] (#connect)
[Testing] (#test)

This guide shows how to deploy and connect a Linus virtual machine running Ubuntu Server 22.04 LTS-x64 Gen2 using SSH public key through Azure portal.

## Create (Deploy) Linus Virtual Machine <a name="create"></a>
### _Step 1: Sign in to Azure portal_
Go to portal.azure.com and sign in. If you do not have a subscription yet, click [here] (https://azure.microsoft.com/en-us/free/open-source) for sign up for free.

### _Step 2: Create a Linus Virtual Machine (VM)_
**a) Create a virtual machine**
On the Home menu, click create a resource.


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

Locate virtual machine and click create. 

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

This will open the basic tab of the create a virtual machine page. 

**b) Configure the VM Basics**

_Under the project details_, select the subscription, create new resource group with any name of your choice or use an existing one. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1g340chx7vzgdqy5pt0t.jpg)

_Under Instance details_, type a name for the VM and select a region. For the availability option, choose No infrastructure redundancy required. select standard for security type. For the image, select Ubuntu Server 22.04 LTS-x64 Gen2. leave the size at default.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qdjb7onnop4kq11rtb0.jpg)

_Under Administrator account_, select SSH public key then enter a username. You can use the default username if you wish. Select Generate new key pair for the SSH public key source and RSA SSH format for the SSH key type. Give a name for the key pair name. The default name is usually your VM name_key. You can change it if desired.

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

_Under Inbound port rules_, select Allow selected ports and check HTTP (80) and SSH (22) from the drop down.

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

**c) Configure other Tabs (optional)**
Having completed the basics tab then click review + create at the bottom of the page to provision the virtual machine or review each tab for full customization. Here, we will leave the other tabs at default setting.

### _Step 3: Review and Create (Deploy)_
Click review and create at the bottom of the page. 

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

Review the details and click create.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jofdsz004s639g7q1wzy.jpg)

 After validation is passed, a Generate new key pair window will open. Select Download Private key and create resource.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/87uhlop7zao88pe5i6p8.jpg)

Your key file will be downloaded with a .pem extension.

**Note: **The location of the key file downloaded should be noted for easy connection through the terminal. You will need to reference the path when connecting to your VM.

[back to top] (#contents) 

## Connect to Linus Virtual Machine <a name="connect"></a>
 
###_Step 1:  Get Public IP Address._
When deployment is completed, click Go to resource.

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

On the new Linus VM, copy the public IP address

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

###_Step 2: Connect to the Virtual Machine_ 
Create an SSH connection with the virtual machine. To achieve this, you will run a few commands in terminals. For a Mac or Linus user, use Bash prompt and set read-only permission on the .pem file. For windows user, use PowerShell or CMD and run as administrator.

When prompted on your opened terminal, open SSH connection by typing
**_ssh -i the path to the private key (the.pem file downloaded) username@public IP address
for example,
ssh -i "C:\Users\HP\Documents\Tina files\Linus-VM_key.pem" azureuser@52.232.125.22_**
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zk7mltcc943et9d0gven.jpg)
If your connection is successful, you will get a welcome message.

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

###_Testing <a name="test"></a>_
To test if your VM is working, run a simple command to update the VM and install a web application (NGINX). 

**a) Update the VM**
Type sudo apt-get -y update 
and press enter 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtaaxigw3pnk1mphckqv.jpg)

**b) Install NGINX**
Type sudo apt-get -y install nginx
and press enter

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

**c) View in Browser**

Open a browser and enter the public IP address of the VM created. The web application will open.

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

[back to top] (#contents)