Step-by-Step Guide to Creating a Linux VM using a Public key

david olagunjudavid olagunju
3 min read

In today’s cloud driven world, virtual machines (VMs) have become the backbone of development, testing and deployment. Whether you’re spinning up a server for a personal project, hosting a website or building out an enterprise-grade application, chances are you’ll be working with a Linux Virtual Machine at some point.


But here’s the catch: how you connect to that machine matters just as much as setting it up. Traditionally many beginners use a password to log in—but passwords can be guessed, stolen or brute-forced. That’s where public key authentication comes in. Instead of typing in a password every time, you could use a cryptographic key pair that is far more secure, faster to use and widely considered the industry standard for SSH connections.

By using this public key, you’re not just logging into your VM, you’re following best practices for Cloud Security. Major cloud providers like AWS, Azure and Google Cloud encourage (or even require) this method, because it greatly reduces the risk of unauthorized access

In this guide, we’ll walk step by step through creating a Linux virtual machine with a public authentication key using Azure. Let’s dive into it!!!


Step 1: Log in to your Azure portal

Step 2: Search for Virtual Machines

  • In the search bar, type “Virtual Machines“.

  • Click on Virtual Machines.

After clicking, you would land on the virtual machines page

Step 3: Click “Create“ - “Virtual Machines“

  • Click Create (top left).

  • Choose Virtual Machine.

  • when you choose Virtual machine, you’ll land on the “Create Virtual machine“ page.

Step 4: Configure the Basics settings

You’ll now see a Basics tab with these fields:

  • Choose your subscription

  • Resource Group — Create a new one or select an existing one (e.g., myResourceGroup).

  • Virtual Machine Name — E.g., (myVM01) and choose the region nearest to you.

  • Availability Options — Decide if you want redundancy.

  • Security type — Decide if you want standard.

  • Image — Choose OS (windows server, Ubuntu, etc.).

  • Size — Pick VM size (e.g., B2s, vCPU, 4 GB RAM).

  • Choose SSH public key and type in your username

  • Choose generate new pair key and type in pair key name

  • Click “Allow selected ports“, then pick SSH AHD HTTP

Step 5: Review + Create

  • Azure will validate your configuration.

  • If everything looks good — Click Create.

  • Click “Download private key“

  • Then the key will be downloaded into your downloads files.

Step 6: Deployment

  • After downloading the key, deployment would start (2-5 minutes)

  • You should get a notification that your deployment is initializing and submitting.

  • Once complete, you’ll see “Your deployment is complete“.

  • Click Go to resource group.

Step 7: Connect to your VM

  • Click Connect.

  • Copy file path and IP address

Step 8: Go to Command prompt or Windows Power shell

  • Paste

  • Now press Enter and you’re connected to your VM

You now know how to create a Linux VM using a public key on Azure, through the steps that have been given above. You also know the difference between using a password and a public key and you definitely which is more secure, better and faster, used by industries and organizations. When you turn on your computer and want to create a Linux VM, try using the public key instead of a password, and you’ll also experience how secure, fast and better it can be.

See you guys in the next post!!!

4
Subscribe to my newsletter

Read articles from david olagunju directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

david olagunju
david olagunju