How to create and connect to a Linux VM on Azure using a Public Key.
Published: 2024-06-22 00:22:48

Table of content.

- Introduction
- Log In
- Step 1: Create VM
- Step 2: Add all Basic Parameters
- Step 3: Review + Create VM
- Step 4: Machine Validation Passed
- Step 5: Create for VM deployment
- Step 6: Connect Linux VM Via SSH

**INTRODUCTION**: Linux Virtual machines is a type of machine that is powered by the Linux operating system. They vary in different types ranging from Ubuntu, Redhat, Oracle Linux and a host of others. For the purpose of this write up we will be working on the Ubuntu Linux virtual machine connecting via SSH using a public Key.

The process is initiated by logging into the Azure Portal to commence creation of your Ubuntu Linux Virtual Machine.

**STEP 1: CREATE VM**

click on create Virtual machine upon accessing the Azure portal as shown in below diagram.

**STEP 2: BASIC PARAMETERS**
Next step will be to add all the **BASIC** parameters to your virtual machine. See steps below:
 a. create a resource group name **(RGLinux)** see 
    highlighted in the diagram below.
 b. Give the virtual machine a name**(LinuxVM)**
 c. Pick your region**(US West US2)**
 d. Select your availability option**( No Infrastructure redundancy required)**
 e. Select security type(Standard for this machine)
 f. From the image tab you will select your linux server type**(Ubuntu server)**
The drop down arrow indicates all dialog boxes you can open to show various options in the instance detail area.

g. Select the size tab to pick the memory size for the Linux virtual machine. there is a dropdown to pick as required for the VM. This comes with monthly billing based on the selected size.

h. Authentication Type is to select the preferred authentication protocol. This can either be SSH Public key as highlighted below or password. In the case of this Ubuntu Linux machine we are using a SSH public key. Note: A public key will be generated which will be used to gain connect to the virtual machine in the chosen terminal. select **HTTP** to give web access when connecting to your linux virtual machine.

i. In the username tab, a username needs to be created or you use the default **azureuser** as highlighted in the below image.

j. You can click on next Disk to proceed to the Disk tab and make the required selection for your Linux virtual machine. This option can also be done when your machine has been deployed and validated.

**STEP 3: REVIEW AND CREATE**

Finally in the Basic tab you will click on. review and create to validate your linux VM. after this command your virtual machine will go through a validation process.

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

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

**STEP 4. MACHINE VALIDATION**

After the review and create, if your virtual machine has no error, you will see the validation passed indicated as shown in the diagram below.
Note: your machine will show you your hourly subscription credit once the validation has been passed.


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

**STEP 5. CREATE FOR VM DEPLOYMENT**

The create button will be clicked for final deployment of your ubuntu linux virtual machine. Here you will find details of your Linux virtual machine before you connect your machine via your preferred terminal.


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

**STEP 6. CONNECT VIRTUAL MACHINE** 

The virtual machine can be connected via SSH using the SSH public key generated during the creation of the virtual machine. A public IP address which was generated while creating the linux virtual machine is also required to be able to connect the VM machine through your preferred terminal. See below diagram:


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