DEV Community

Cover image for Setting Up a Linux Virtual Machine with Azure on a MacOs using Password Authentication (Part I)
Tunde Oretade
Tunde Oretade

Posted on

Setting Up a Linux Virtual Machine with Azure on a MacOs using Password Authentication (Part I)

Introduction

This is the first installment of a two-part post focused on creating a Linux virtual machine with Azure. If you have been following my journey into cloud development, I have written about setting up a Windows virtual machine in Azure too.

Two authentication approaches can be used to set up the Linux virtual machine. This post will focus on one which is the password authentication

As I have suggested in previous posts about setting up virtual machines, having a Microsoft and an Azure account is a prerequisite for following the steps in this post.

Step 1: Create a Linux Virtual Machine

  • Log in to Azure portal
    Azure Portal

  • Search Virtual Machine using the search bar at the top of the page.

Search Bar

  • Click the + Create icon at the top of the page or click the Create button at the bottom to create a virtual machine. create buttons Azure Virtual Machine

Basics Tab

Basics Tab

  • Under Project details, name the Resource Group or choose a Resource Group Project details

Resource group

  • Next, give the Virtual Machine a name.

Virtual machine label

  • At the Region label, select an appropriate label.
    Region

  • For the Availability Options label, select Availability zone.

Availability Options

  • At the Availability zone label, select zone 2 (I selected zone 2 in mine. However it may be different in yours).

Availability zone

  • Security type label should be set at Trusted launch Virtual Machines

Security type

  • The Image label should be set to Ubuntu Server 22.04 LTS x64 Gen2

Image

  • VM Architecture should be set to x64.
    VM Architecture

  • Do not tick Run with Azure spot discount box
    Run with Azure spot discount

  • Set Size to Standard_B2as_V2..
    size

  • Do not tick Enable Hibernation box as well.

Enable Hibernation

  • Under Administrator Account heading, Set Authentication type to Password. I will handle SSH Authentication in part two of this post.

Authentication type

  • Set Username, Password and confirm Password subsequently.

username & password

username

  • At Public inbound ports label, select Allow selected ports, and
    Public inbound ports

  • for the Select inbound ports label, at the dropdown, tick HTTP (80) and SSH (22). HTTP was selected as part of the ports because I will access the server via a browser at some point in this post.

Select inbound ports

HTTP & SSH

Monitoring Tab

  • Click Monitoring at the top of the page Monitoring
  • Click Disable to disable diagnostics. This is to prevent third-party access. Disable

Tags Tab

  • Under the Tag Tab it is ideal that name and value are created for the resources. Give the resource a name and value In the annotated part of the image below. They help to categorize resources. Both the name and value are called Tags.

Tags

  • Click the Review + create tab or the Review + create button at the bottom of the page.
    Review + create

  • Click the Create button to complete the configuration process.
    Create
    initialising deployment

  • After the complete deployment, click the go to resources button. This completes the creation of the virtual machine.

go to resources

  • The next thing to do is to increase IP address timeout to prevent untimely shutdown.

  • At the Virtual Machine overview page, click on the IP address at the IP address label
    IP address

  • This re-directs to an IP configuration page. While on the page move the idle timeout slide to the right hand of the page.

IP configuration page

  • Click the Save icon at the top of the page. Save
  • Close this page by clicking the close icon at the top right. close icon
  • Copy the IP address at the Virtual machine interface.

Step 2: Connect to the Linux Virtual Machine

  • To connect to the Linux Virtual Machine, Open the terminal.
  • Type in ssh username@IP address at the terminal. The Username used here was created while providing information for the Administrator account in the above steps, while the IP address was copied when the deployment process was complete.
    terminal

  • The prompt asks if you want to continue, type yes

prompt

  • Provide the required login password when prompted again.
  • Then the prompt changes to a combination of the username@virtual_Machine_Name. This is evidence of a connection to the Linux Virtual Machine.

proof of connection

Step 3: Install Nginx Server in the Virtual Machine

  • The next step is installing a Nginx server in the Linux Virtual machine. To do this, log in as the root in the Virtual Machine.
    At the terminal type in sudo su to change to root user.
    root user

  • At the next terminal/prompt type apt install nginx to install ngix.
    Nginx

  • Select yes at the next prompt. This completes the Nginx installation process.
    another prompt

Step 4: Testing the Linux virtual Machine via browser

  • To test if everything works perfectly, copy the Linux Virtual Machine IP address from the Azure portal and paste it into a browser. If you can see the image below in your browser, it means everything is working well.

Browser confirmation

Conclusion

This concludes my post on creating a Linux Virtual machine in Azure using Password Authentication.
It is advised that the resource created in the Azure portal be deleted when not used.
In the next post, I will write about creating a Linux Virtual machine in Azure using SSH Authentication.

Top comments (0)