HOW TO CREAT AND CONNECT TO A LINUS VM USING A PUBLIC KEY.

anthony AMAJOH - Jun 21 - - Dev Community

Here are the steps to creating and connecting to Linus VM using a public key.

_Sign in to Azure
Create a Resource Group
Create SSH Public Private Key Pair
Create Virtual Machine
Connect to Virtual Machine.

SIGN IN TO AZURE
To sign to Azure. Type in "portal.azure" on the web browser to open the Azure portal. Enter your email and password on the login page, and sign in.

Image description

CREATE A RESOURCE GROUP OR USE AN EXISTING RESOURCE GROUP
To create a Resource: on the search bar, type in virtual machine. Select virtual machine from the dropdown.

Then click on 'Create' and select Azure Virtual Machine.

Image description

Image description

From the "Create a Virtual Machine" page, create a new Resource Group or select from an existing resource group.

Image description

CONFIGURE BASICS
Choose a VM name
Region
Availability Option
Security Type

Image. This refers to the OS. In this case, we are working with Linus OS
Size

Image description

CREATE SSH PUBLIC KEY
"Administrator Account"
For Authentication type under "Administrator Account"; select SSH Public Key.
Azure automatically generates an SSH Key Pair and allows you to store it for future use. It is a fast, simple, and secure way to connect to your VM.

Username. A default username is created, this can also be changed.

SSH Public Key Source. A new Key Pair is generated by default. If you already have an existing key pair; select any other suitable option from the dropdown bar.

SSH Key Type. Select RSA SSH format.

Key Pair Name. Automatically named. It is named after the VM with _key (underscore key) added at the end as a "suffix".

Inbound Port Rules
Public Inbound Ports. Allow Selected Ports is selected.

Select Inbound Ports. HTTP(80), and SSH(22)

See attached screenshot

Image description

Since we are creating a simple Linus VM; the settings for Disks, Networking, Management, Advance, and Tags will remain at default.
We can go ahead and click "Review and Create". In the future, if and when the need arises; the default settings can be changed in the VM's settings.

After clicking 'Review and Create'; the validation page will come up. See below screenshot

Image description

We can then proceed to create the VM by clicking create at the bottom of the page.

A prompt will pop up requesting a download of the Private Key as shown in the screenshot below. Click download and wait while it downloads and deploys. This might take a while, it is downloaded automatically to the download folder

Image description

After deployment is completed, click on Go To Resource.

Image description

After clicking on 'go to resource', the overview page of the Linux VM will open.

CONNECT TO THE VM
To connect to the VM, open cmd or powershell. Then, type in ssh -i "the path of the downloaded key pair,the generated key pair name.pem" azureusername@ip address and press enter. The screenshot below shows connection to the VM was successful.

Image description

After successfully connecting to the VM, you can then, go ahead and install web server and connect to nginx by running sudo commands.

Image description

Since this VM is for test purposes; it is important not to leaves the resources running as the idle resources will be incurring costs. It is advisable that we delete the resources.

. .