DEV Community

Emmanuel Ukoha
Emmanuel Ukoha

Posted on

How to create a Linux VM and SSH into it

Hands-On Lab on Creating the Azure VM (Linux (ubuntu 20.04)
There are 3 primary steps in creating the Azure VM (Linux (ubuntu 20.04).

  1. Create virtual machine in the Azure Portal + Configurations
  2. Test the Connection
  3. Install Web Server & View the Web Server in Action

1. Create virtual machine in the Azure Portal + Configurations

Go to your Azure Portal. Now, on your left-hand side, click “Virtual Machines”. If this is your first time creating VMs, then you will not see any instances running. Proceed “Create Virtual Machine”.

Image description

Image description

For “Project Details”, make sure the correct subscription is selected.

Image description

In administrator account, provide the admin username for the VM and Generate an SSH public key.

Image description

Make sure you select HTTP for web access

Image description

Then, I will leave the rest of the configurations by default. Proceed “Review + Create”. Wait until the deployment is successful.

Note: Make sure it passes Validation

Image description

Download the PEM Key.

Image description

Congratulations!!! You just created a Virtual Machine

Image description

2. Test the Connection

Image description

Step 2: Specify the location of the PEM file on the
ssh -i azureuser@xxxxxx.pem

Image description

Open your PowerShell and paste the path and enter, select yes on the prompt

Image description

Once in the VM.

3. Install Web Server & View the Web Server in Action

Install Web Server & View the Web Server in Action
Type the following in the PowerShell

The first command is checking for any Ubuntu updates.
Update Ubuntu server
sudo apt update

The second command is installing Apache with the “-y” option to skip required “Yes” prompts during the installation.

Install Apache Server
sudo apt -y install apache2

After running both commands, go over to the Azure Portal and copy out the Public IP

Note: if for some reasons you can't access the Azure Portal immediately, Type in the following commands to get the IP Address

This command is to find the public IP address you’ll want to input into your browser to verify that the installation has gone correctly. This is what the webpage should look like:

Find current IP address
curl https://ipinfo.io/ip

Now your type the IP on the browser and enter.

Image description

If you got the above image, congratulations, you just installed a Linux VM and also installed a Web Server.

Did you succeed or still have issues?

Comment Below!

Top comments (0)