Table of Contents
Create (Deploy) Linus Virtual Machine
Connect to Linus Virtual Machine
Testing
This guide shows how to deploy and connect a Linux virtual machine running Ubuntu Server 22.04 LTS-x64 Gen2 using SSH public key through Azure portal.
Create (Deploy) Linux Virtual Machine
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 for sign up for free.
Step 2: Create a Linux Virtual Machine (VM)
a) Create a virtual machine
On the Home menu, click create a resource.
Locate virtual machine and click create.
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.
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.
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.
Under Inbound port rules, select Allow selected ports and check HTTP (80) and SSH (22) from the drop down.
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.
Review the details and click create.
After validation is passed, a Generate new key pair window will open. Select Download Private key and create resource.
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.
Connect to Linux Virtual Machine
Step 1: Get Public IP Address.
When deployment is completed, click Go to resource.
On the new Linus VM, copy the public IP address
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
If your connection is successful, you will get a welcome message.
Testing
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
b) Install NGINX
Type sudo apt-get -y install nginx
and press enter
c) View in Browser
Open a browser and enter the public IP address of the VM created. The web application will open.
Top comments (0)