Step-by-Step Guide: Creating and SSH Access to a Linux Virtual Machine on Azure

A Linux Virtual Machine (VM) refers to a virtualized instance of a computer running a Linux operating system.
As cloud computing continues to reshape the technological landscape, platforms like Microsoft Azure offer a wide array of services to help individuals and businesses harness the power of the cloud. Creating a Linux Virtual Machine (VM) on Azure is a fundamental skill for anyone looking to deploy applications, run services, or simply explore the world of cloud computing. In this step-by-step guide, we'll walk you through the process of setting up your very own Linux VM on Azure.
Step 1: Sign in to Azure Portal
If you don't have an Azure account, you can sign up for a free one.
Open your web browser and navigate to the Azure Portal, sign in with your Azure account credentials.
Step 2: Create a Linux Virtual Machine
Click on the "Create a resource" button (+) in the Azure Portal.

Search for "Ubuntu Server" or your preferred Linux distribution and click on "Create".

Fill out the required information for the VM, such as having a funded subscription.

If you do not have a resource group, then you create one and click on OK.

Get a name for the VM.
Get a region close to you to manage costs.
Select availability option and select security type.
Choose the appropriate Image or operating system and virtual machine size.

For authenticator type, Set up an administrative username and SSH public key or password for the VM.
In this article, we are getting the username and SSH public key for the VM as illustrated below.

Step 3: Configure Networking
Configure inbound security rules to allow SSH traffic (port 22) from your IP or any secure source.

Next, leave every other field as default and select monitoring(you either disable or enable monitoring)

Step 4: Review and Create
Review all the settings and configurations you've made.

Once validation is confirmed, click the "Create" button to deploy the Linux virtual machine.

Before deployment takes place, a prompt might pop up to download a new private key pair because we generated a "new key pair". (Note that using SSH keys is for improved security)
Click on "download private key and create resources" the key will be downloaded and Azure will start creating the VM based on your specifications.

Step 5: Wait for Deployment
The deployment might take a few minutes but you can monitor the progress on the Azure Portal.
Once the deployment is complete, select "Go to resources"
The private key should be downloaded and opened in your local machine folder(note that the private key should not be accessible to everyone)

. Step 6: Getting Public IP
Once the VM deployment is complete, navigate to the VM's page in the Azure Portal. Here, you'll find the public IP address of the Linux VM as illustrated below, Make note of it.

Step 7: SSH into the Linux VM
On your VM overview select connect to take you to the next page where you will see how to connect to your local machine,click on select.


next you will get the configuration prerequisite for your local machine as in the picture below

After the configuration is completed, you will have to copy the path to your SSH private key downloaded(this should be downloaded in your local machine file)

Click on your file explorer, click on download, right click and "copy as a path" , then go back to Azure portal and paste in the space provided, then copy the link below it to SSH to VM with specified private key .


NOTE: At this point we will need open command prompt on your local machine but before that, you must have installed Azure cli. Use the link below to download and install.
https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
Open a terminal or command prompt on your local machine and type
'az login' for authorization.

You will be required to select your login details on a new tab on your browser, once verified, you get logged successfully and you close the tab afterwards.

Go to the command prompt, your details as a user will be there.

On the azure portal, copy the specified private key as indicated earlier and paste in the command prompt.

Step 8: You're In!

Once connected via SSH, you'll have command-line access to your Linux VM, you can now manage your VM, install software, and perform various tasks.
Remember to secure your VM by regularly updating the system and adhering to best security practices and When not in use, consider stopping or deallocating the VM to save on costs.
By following this step-by-step guide, you've learned how to create a Linux virtual machine on Azure and securely connect to it using SSH. This foundational knowledge opens doors to exploring more advanced Azure features and services.
lastly, the Azure portal interface may change over time, so the exact steps and options may vary slightly. However, the general process outlined above should provide you with a good understanding of how to create a Linux VM on Azure.
Remember, practice makes perfect. The more you work with Azure and virtual machines, the more confident you'll become. Happy cloud computing!




