Unleash The Power of Azure: Creating A Linux VM with SSH keys Security.

Unleash The Power of Azure: Creating A Linux VM with SSH keys Security.

Hey dev.to community! Ready to level up your cloud game? Today we’re diving into Microsoft Azure to create a Linux virtual Machine(VM) with the added security of SSH keys. Ditch those risky passwords and embrace a more secure way to access your cloud resources.

Why SSH keys on Azure?

Let’s kick things off with a quick rundown of why SSH keys are the way to go for your Azure VMs:

Fortress-like Security: SSH keys offer solid protection against brute-force attacks, making your VM virtually impenetrable.
Streamlined Access: Say goodbye to typing passwords every time you log in. SSH keys make connecting to your VM seamless.
Automation Ace: SSH keys are a delight for automating y=tasks like deployments, updates and maintenance on your VM

What You’ll Need For This Adventure

An Azure Account: No account? No problem! Signv up for afree Azure trial to get started.
Linux Knowledge: Basic familiarity with Linux commands, and Azure portal will make it a breeze.

Let’s Build Your Linux Fortress!
Step 1: log in to Azure portal
Head over to Azure portal(https://portal.azure.com/) and log in with your credentials.

Step 2: Create a New Virtual Machine
Just like creating a windows VM from our last post:

Go to the search box and type “virtual machine” then click.
On the Virtual machine page, click “Create”, under create click on the option “Azure virtual machine”

Create a Resource group
Name your VM (e.g. “MyLinuxVM”).
Select your region(for optimal performance, choose one close to you).
Choose an Availability zone(e.g. Zone 1, 2 or any other option peculiar to you)
Leave security type in its default state(Trusted Launch)
Under “Image”, pick your preferred Linux distribution e.g. Ubuntu.

Step 3: Authentication

Under “Authentication Type” select “SSH public key”

Configure Your VM

Choose the VM size that matches your needs, start small; you can always scale up later

Set up network if needed:; you can leave at default network provided by Azure.

Inbound port should be on SSH(22)
_ Leave every other configuration at their default for now as our main focus is creating a VM with Linux OS

Step 5: Review and Create

Give your settings a final check and click “Create”. Azure will get to provisioning your Linus VM once your validation is passed.

N:B Validation may not get passed when some of your configurations(Network, image, region, resource and others) are not complete or unsupported by Azure at the moment or by Azure services. Once you get such feedback, you can go back and double check where the error lies, then align.

While Azure is provisioning your Linux VM, copy the prompt on your screen “Download private key and create resource”

Just like the windows VM, your deployment gets complete

Step 6: Connect with your SSH key

Click on “Go to resources” select “Connect” then “Native SSH” this opens up instructions on how to connect to your Linux VM, but we shall connect using the CLI or the Powershell.

Open a CLI or Powershell from your PC

Type in the following command “ssh -i /path/to/your/private key/ your vmuser@yourvmpublicIP for example:

ssh C:UsersUserDocumentsMytestubuntu_key.pem azureuser@ 20.75.82.93 press “Enter”

And Voila! here comes your Linux VM interface