A Beginner’s Guide to Installing a VM on Azure — Running Your Website on an Azure Cloud VM: Anytime, Anywhere Access Made Easy

Muhammad Huzaifa
11 min readMay 9, 2023

--

As students related to the fields of computer science, I myself especially as a student of Cyber-Security, we all need to install several numbers of operating systems like Flare, Ubuntu, kali on our own systems either bare metal or in form of virtual environments. But no matter what the case, this always is a waste of your storage and compute consumption. Plus, the fact there are people who cannot afford using multiple environments at the same time on their devices. Today we are going to take a look at one of the most convenient solutions for this issue i.e., creating a virtual machine on a cloud environment i.e., Microsoft Azure.

Yes, today we are going to take a look at how we can create a virtual machine on Azure without having to worry about the storage and compute consumption. So, this blog basically covers three main parts:

· Creating a virtual Machine on Azure

· Using Remote Desktop RDP for GUI of installed VM and SSH for Kali’s CLI

· Setting up an Apache server to let world connect you without even having your own domain.

Following are requirements you need to fulfill before getting started:

· Just a good internet connection

Isn’t that amazing.

So, without any further ado, let’s get started.

Creating a virtual environment on Azure

Before creating a virtual machine on azure, 1st of all if you don’t already have, you need to create your own Microsoft azure account. In this blog I since have already created my account i.e., a student subscription account. So, I am going to start this blog right where we can start creating our virtual machine.

So, get to your Azure portal at https://portal.azure.com/#home and you will see an interface like this, where you will be needing to select the virtual machine cell somewhere in the line in front of “create a resource” cell.

Selecting the virtual machine option will get you to the actual virtual machine creation page where you need to select “Azure Virtual Machine” from the drop down with the create tab as shown in the screenshot below:

You will be redirected to a new page where you will have to provide some information related to the virtual environment you are about to create. But 1st you need to select a resource group. You can either create a new one or carry on with an already created one, its your choice, I however will be creating a new resource group here by the name of “Virtual-Machines.”

Provide the name of the virtual machine, the region you are nearest from like I chose “Central India” the nearest region from Pakistan. Next under Availability options select availability Zones and in Availability Zone specify the zones where you will be keeping your environment or say backup of environment in case of any disaster destroying any of the zones. I, however, will be proceeding with only one zone.

Next step is selecting the security and image of the virtual machine you want to install. In this scenario I am going to install Kali Linux on Azure.

Note

Creating windows based virtual machines cost more than Debian based operating systems since you need to consider the cost of licenses as well while Linux are open source.

If you can’t see the desired image file, select see “all images” and find the one you want to install. Select a 64-bit architecture and size of your virtual machine as shown in the screenshot below:

Click on “see all sizes” to select the one you require.

For the administrator account select password instead of SSH since we are going to need this in later stages.

Now, in this blog at the end we are going to create a simple site on apache server, and we also want it to get accessed over the internet, therefore I am going to allow all ports in the inbound ports section.

Below the public inbound ports select “Next: Disks” section. Usually, Azure takes care of VM disks on its own but if you want to change it you can do it from here.

I selected a standard SSD since I am going to use my VM for general purposes, I don’t have need of the premium SSD or any desire to charge myself for that premium cost.

Now, there are several other tabs that you can explore like networking, but since azure takes care of all of them on its own. We do not need to get ourselves wrapped up in that. So just click “review and create” at the bottom left of the screen.

It will take some time to validate the settings and then you can see a window like this:

Azure provides you with the cost of the resource you are going to pay for an hour of active resource. For instance, I’ll pay $0.1790 if I run my VM for one hour. At this time, you will verify your settings and deploy the virtual machine by clicking the create button. You can see that the VM is being deployed.

After deployment is complete click “Go to resource” button. This will redirect to a page where all the information related to the virtual machine you have created will be shown.

As you can see in the screenshot above, by default the virtual machine is running after being created. You can see your public/ private IP address and all the other information related to the underlying operating system.

Now our VM is running but how do we access it, to do that click on the connect tab highlighted in the above picture and you will see a windows like below:

Here you get different options to access your virtual machine but the most usable are SSH and RDP. Using SSH we can connect to our virtual machine, but it is limited to terminal only and cannot provide the graphical user interface. So, let’s see how we will connect to the virtual machine’s CLI using SSH and to the GUI of Kali using RDP.

Using SSH to connect to VM’s CLI

Connecting to the VM’s CLI you just created is pretty simple. Just follow the following steps:

· Use the following command in your CMD

"ssh <username>@<Public IP address>"

· Confirm the fingerprinting by typing Yes.

· Enter the password you set while creating the virtual machine.

You can see in the screenshot below that you have been connected to the CLI of the virtual machine you just created.

You can run any and all commands that you can run on terminal of a dual booted or virtualized kali Linux environment on a system. You can install any package; you can run updates and do every command line doable thing on this terminal. Plus, you get a full Debian based command line interface in your windows command prompt without any lag or disturbance.

Like I wanted to install a tool named neo-fetch, and I simple used “apt-get install” command to do that as shown in the screenshot below:

Connecting and Using VMs GUI using RDP

To connect to the GUI of the installed environment you need to select the RDP option instead of SSH and download the remote desktop file provided for your virtual environment as shown in the screenshot below:

Now before doing anything with this downloaded file, we need to do some configuration as below:

· In the side blade of the overview page of your VM select “Networking” and on the window shown select “add inbound port rule”.

· To be able to connect to the RDP file you will be needing to allow the traffic on port 3389 for RDP as shown below:

· You can see that the new rule for inbound port traffic has been added.

Now open the downloaded RDP file and you will get a prompt like this:

Click the connect button and try connecting to the GUI of the VM you created above.

You will get an error like this presented above. This is because you have neither installed RDP on your VM nor have setup an XFCE session which will be responsible for providing the kali’s GUI. To configure this, you need to follow a few steps described below:

· Install RDP on your VM using the following command

sudo apt-get install xrdp.
  • Select “English US” language.

· Add RDP certificate and restart the service using the command shown below:

sudo adduser xrdp ssl-cert && sudo systemctl restart xrdp
  • Install UFW to allow traffic on port 3389 for RDP using the following command
sudo apt-get install ufw

· Allow the traffic using UFW using the command below

sudo ufw allow 3389

· Install XFCE session for Kali’s Graphical user interface using the command shown below:

sudo apt-get install xfce4-session xfce4-goodies xrdp

This was all now try connecting to the remote desktop server through opening the RDP file downloaded before again and you will get a new window like this:

Click yes to proceed. And Viola! We are connected to the GUI of Kali Linux.

Anything you could do on bare metal or Kali Linux virtual machine is available here, but here you will not be worried about the system upgrades and configuration, maintenance of underlying architecture, storage, and computational power of your system since all of this is being dealt by the Azure itself. Now, let's get to the last part of this blog that is:

Hosting Site on Apache server accessible to whole world

The 1st step we needed to do is installing the Apache server on Linux. You can install it using the following command:

sudo apt-get install apache2

Check the Apache status using following command:

sudo service apache2 status

If the server is dead/ inactive use the following command to start it:

sudo service apache2 start

Now if you will check the status, you should have the Apache server online as shown in the screenshot below:

Secondly, install a browser if not already installed as I installed Firefox:

Now if you browse your localhost, you should see your Apache servers’ default rendered index.html as shown below:

I wanted to host my on site on it. So, I changed the content of index .html with content of my on site as you can see in the screenshot below:

Now if I show you my site on my localhost it will be seen something like this:

Now, this site of mine, even if it is running on my Apache server at my localhost, anyone in the world can access this site using my public IP address. I asked my friend to have a look at the site using my IP address and he sent me this picture.

Note

Making it clear at this point that all of this effort you took connecting GUI of the VM you created is a one time work. The next time you start the VM you can easily connect to the GUI simply by running the downloaded RDP file.

Conclusion

In conclusion, installing a VM on the cloud provides many benefits to users. One of the key advantages is that it allows users to save their own storage and computational power, which can be crucial for businesses that require high-performance computing. Additionally, cloud computing can be significantly less costly than traditional methods of hosting and managing data centers.

Moreover, if you run a website on an Apache server hosted on your cloud VM, it can be accessed from anywhere in the world, even if you don’t have your own domain or hosting. This makes cloud computing an ideal solution for businesses or individuals who need to access their data and applications from various locations.

Overall, the benefits of using cloud computing are clear. By leveraging the power of the cloud, users can enjoy increased flexibility, scalability, and cost-effectiveness in managing their computing needs.

--

--

Muhammad Huzaifa
Muhammad Huzaifa

Responses (1)