DEV Community

Folashade Chijioke
Folashade Chijioke

Posted on • Updated on

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! Sign up for a free 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"

Image description

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

Image description

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.
    Image description

  • 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

Image description

Image description

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.

Image description

  • 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

Image description

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.

Image description

  • 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:\Users\User\Documents\Mytestubuntu_key.pem azureuser@ 20.75.82.93 press "Enter"
    

And Voila! here comes your Linux VM interface

Image description

Top comments (1)

Collapse
 
fola2royal profile image
Folashade Chijioke

Hello Techies thank you for your reactions on my posts i need more reactions and comments, let's keep it rolling in.

Thank you in advance.