Creating a Linux Virtual Machine in Azure using an SSH Authentication Key
Tags: azure, linux
Published: 2024-04-15 01:49:19

A Linux VM is a virtual machine that runs Linux as its operating system. A virtual machine is like having a computer within a computer, where the cloud provider allocates resources such as memory, processing capabilities, and storage to the VM. This enables the VM to operate independently, running its operating system and applications just like a physical system.

How can one create an Azure Linux VM?
It is done by either using 
i) Password or 
ii) Secure Socket Shell (SSH) KEY 

Let's consider how it is done using an SSH Key.

Login into your Azure account based on **subscription** or you can check on how to get a [free account](https://k21academy.com/microsoft-azure/create-free-microsoft-azure-trial-account/). Then go to the home page and click on virtual machine. Apply the following steps:

STEP 1: Type in your subscription
STEP 2: Create a new resource group
STEP 3: Type a name for your virtual machine
STEP 4: Choose a region.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ckgl38groaun1c67q5q.png)
STEP 5: Select availability zone
STEP 6: Choose a particular zone
STEP 7: Select the security type you want
STEP 8: Choose an image(in this case, Linux) 
STEP 9: Choose a size 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0szupwhqqbgrc77gnt2e.png)
STEP 10: Click SSH public key
STEP 11: Type a username 
STEP 12: Under SSH public key source, click on generate new key pair
STEP 13: Under key pair name, enter the name of your choice 
STEP 14: Under public inbound ports, Click on 'Allow selected 
ports'
STEP 15: Under select inbound ports, click on SSH(22)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ng8y6f331l1wf24vbw6k.png)
STEP 16: At the top, Click on Review and Create
STEP 17: Once you see validation passed, click on create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3tjncw1taw03febd1cd.png)
STEP 18: Click on 'download private key and create resource'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1m6yp23tl1mhwmg3mz2o.png) 
You will see on the screen 'Deployment is in progress' 
On your browser check for the downloaded file _(We will be needing it)_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zny1nb2659ogjbesipq6.png)
STEP 19: Once deployment is complete, click on 'go to resource'

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i39g207phq1yzxl3u015.png)

STEP 20: Go to the downloaded file, right-click on it and click properties

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvhzyoqshxwzdvzqp4br.png)

STEP 21: Click on security, copy and save the object name perhaps on a sticky note for easy access. This is the **key path**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4hkfiz8jnsutkkcyyyg.png)
STEP 22: Now on your azure page, click on connect

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rrmxy2owctdz8s3132s.png)

On the next page, copy the ip address and admin username on your sticky note for easy access.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ym3hesr0nreh02r84w8.png)
STEP 23: Open Windows PowerShell on your system by using the search bar to search for it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tfq94zq5fns2hdge2vz.png)
STEP 24: On the PowerShell, type ssh -i (give a space) followed by the key path (give a space) followed by your admin username followed by @(no space)your ip address and press ENTER

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk34xebfecvnf5ntfwlj.png)
STEP 25: Next type yes

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ty4ytb2u1q6fbi4c2jhk.png)

**_Now your Linux VM is ready for use!_** 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ql4wko24s7om9pne3ifq.png)

Feel free to comment, like and share your thoughts on the article.