DEV Community

Cover image for HOW TO CREATE AND CONNECT TO A LINUX VM USING A PUBLIC KEY.
Temidayo Adeoye
Temidayo Adeoye

Posted on

HOW TO CREATE AND CONNECT TO A LINUX VM USING A PUBLIC KEY.

Azure Virtual Machines (VMs) can be easily created using the Azure portal, a browser-based interface for managing Azure resources. This guide will show you how to deploy a Linux VM running Ubuntu Server 22.04 LTS and connect to it via SSH to install the NGINX web server.

Step 1: Sign in to Azure

Sign in to the https://portal.azure.com/

Step 2: Create virtual machine

  • Search for Virtual machine

Image description

  • Select the subscription and resource group

Image description

  • Select the virtual machine name, region, availability options, security type. Image should be Ubuntu

Image description

  • Size

Image description

  • Under Administrator account, select SSH public key.

In Username enter azureuser.

For SSH public key source, leave the default of Generate new key pair, and then enter VirtualVM2_key for the Key pair name.

Review and create

Image description

  • On the Create a virtual machine page, you can see the details about the VM you are about to create. When you are ready, select Create.

Image description

  • Click on download private key and create resource. The file will be download as VirtualVM2_Key.pem. Go ahead and copy the key for the next step

Image description

Your
When the deployment is finished, select Go to resource.

On the page for your new VM, select the public IP address and copy it to your clipboard.

Step 3: Connect to Virtual Machine

  • When the deployment is finished, select Go to resource.

Image description

  • On the page for your new VM, select the public IP address and copy it to your clipboard.

  • Create an SSH connection with the VM on your power shell using the following command prompt

The pem key and the public IP address

Image description

Respond with a yes

Image description

sudo apt-get -y update
Image description

sudo apt-get -y install nginx

Image description

Step 4: Open your IP address on your computer

Image description

Top comments (0)