Creating an Azure Linux virtual machine and connecting to it using SSH
Tags: virtualmachine, ssh, azure, beginners
Published: 2022-04-18 19:35:31

Hi there,

I would like to walk you through on how you can create an Azure Linux Virtual Machine and connecting to it using SSH.

A Virtual machine (VM) is a software computer used as emulation of an actual physical computer. It includes virtual processor, memory, storage and networking. VMs are known for their flexibility and portability and provides many benefits, such as: cost savings, agility and speed, lowered downtime, scalability and security benefits.

For creating Azure VM, you will need to have a valid Azure account. If you do not have one, create using **Azure Portal** for free.

- From the search box, type in virtual machines. Under Services, select Virtual machines.![Virtual machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r13j782i7sjosvhtqvn7.PNG)
- Select **create** shown on the upper left side and then Virtual machine. The **Create a Virtual machine** page opens.![Create Virtual machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6ryecv61cp3nypf06mm.PNG)
- On the basics tab, fill in the following![Basics tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ky17fzjz78gt9or3lerk.PNG)
See below on how I filled out the details![Instance details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6h0b3yxi7w78ysqp0dq.PNG)![Administrators account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i43cqu7p84jnk9x28xu.PNG)![Inbound port rules](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1iupobtm0w7a0hvl8xhs.PNG)
- Leave the remaining defaults and select the **Review + Create**
- Click on **create** once validation is passed.
- Once you click on create, you would be prompted to download private key and create resource. Select and wait for it to download. Make sure you know where the file was downloaded, you will need the path to it in the next step.![key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0eyb5292kynd5wur34q.PNG)
- After downloading, it will immediately submit the deployment template for the resource group.
Once deployment is complete, select Go to resource![Deployment complete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b10bh99ntcico0m687ek.PNG)
**Connect to Virtual Machine**
- On the overview page of the Virtual machine, select the Pubic IP address![Virtual machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aegio1q7k86uex1j6lfr.jpg)
- Change the IP address assignment from dynamic to **static** and click on save afterwards![IP address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0l7m56yyk5g329ozizru.PNG)
- Connect to the VM using **SSH**![connect to ssh](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro27eqfon90gmge7cgru.PNG)
- Copy out the highlighted command in 4 and paste it in your notepad![SSH](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcusxhhz8jibusgd95sc.PNG)
Note the following
- Go to your notepad where you pasted the command highlighted in yellow above
- Also, go to your downloads on your PC and right click the key PEM file download and select properties
- Copy out the key and the location name separately to the note pad opened earlier![command to connect to VM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/756lfkmcqmrezipbz4xk.PNG)
- Merge the key and location name into one with a backlash![key and location name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdd8exzk5sveaap609rf.PNG)
- Copy the above to the **<private key path>** on the command pasted before![SSH key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z52yb3gnlm59gphr9af3.PNG)



Open Windows PowerShell and copy and paste the SSH keypair above. 



To run a command as administrator 'root user', type sudo su. To confirm it is an Ubuntu type of Linux, run the command apt update.




Let me know if this was helpful. I love feedback😊