DEV Community

Cover image for Create and Deploy a Linux Virtual Machine on Azure using a Public Key
Oluwafemi Adebayo
Oluwafemi Adebayo

Posted on

Create and Deploy a Linux Virtual Machine on Azure using a Public Key

Table of Contents

  1. Prerequisites
  2. Create a Linux Virtual Machine
  3. Deploy and Connect to Your VM
  4. Connect to your VM using SSH

Prerequisites

  • Azure subscription
  • Basic knowledge of Linux Virtual Machine (LVM)

A Linux Virtual Machine (VM) is a self-contained, software-based environment that mimics the functionality of a physical computer. By allocating resources from the host system, such as processing power, memory, and storage, the VM runs its own operating system (Linux) and its applications independently, creating a virtual computer within your existing system.

This article provides step-by-step instructions on deploying a Linux virtual machine using the Azure portal.

Step 1: Create a Linux Virtual Machine

  1. Log in to the Azure portal [https://portal.azure.com]
  2. Use the search box to search for and select "virtual machine"
  3. Click on create and select Azure virtual machine

Virtual machine page

  • continue to complete the configuration on the basic settings
  • select the size
  • create a username
  • check the HTTP (80) and SSH (22) box on the select inbound ports
  • click on review + create

basic settings configuration
basic settings configuration

Step 2: Deploy and Connect to Your VM

  • After the validation passes, click create to deploy your VM
  • When prompted, select "Download private key and create resource".

deploying VM

  • Wait for deployment completion, then select Go to resource

resource

  • click on overview and ensure the virtual machine Status is Running.
  • select Connect and Connect in the drop-down.

Overview

Step 3: Connect to your VM using SSH

  • Open a CMD window so you can run the SSH connection string.

cmd prompt

  • At the prompt, connect to the virtual machine using SSH. ssh -i 'c:\users\admin\downloads\VM1_key.pem' adminuser@public_ip_address

To get the correct path to the key, click on your file explore, go to download, right click on the VM file (key path) and click on properties.
click on security, then copy the path to the key on the object name

key path
key path

When prompted, type yes to connect.
Ensure the command is successful and the prompt changes to adminuser@VM1.
Fetch the list of available OS updates and install updates. When prompted, type yes to continue. Each command must complete successfully.

sudo apt update
sudo apt install nginx

Copy and paste the VM Ip address on the browser to launch the Nginx welcome page.

nginx

In conclusion, Linux Virtual Machines provide a flexible and scalable way to run Linux operating systems on various cloud platforms. With easy creation and deployment options, Linux VMs are ideal for development, testing, and production environments.

Summary:
We discussed Linux Virtual Machines (VMs) and explored various aspects, including:

  1. Definition: A Linux VM is a software emulation of a physical computer running the Linux operating system.
  2. Creation: Explored methods to create a Linux VM using Azure portal.
  3. Connection: using SSH to connect the VM

Top comments (2)

Collapse
 
programmerraja profile image
Boopathi

This is a great step-by-step guide to deploying a Linux VM on Azure! I especially appreciate the clear instructions on using SSH to connect, including the key path details. I'm going to try this out myself.

Collapse
 
techiefm profile image
Oluwafemi Adebayo

Thank you so much! I'm glad you found the guide helpful. Good luck with your deployment, and feel free to reach out if you have any questions!