Press "Enter" to skip to content

Create and use an SSH public-private key pair for Linux VMs in Azure

How would you like to connect to your virtual machines securely? Did you know that VMs created using SSH keys are by default configured with passwords disabled, which greatly increases the difficulty of brute-force guessing attacks?

In this step by step guide to Create and use an SSH public-private key pair for Linux VMs in Azure, I show you how to implement these secured practices in a heart-beat using your favourite PuTTY software.

What you need to do first;

  1. Download Putty
  2. Create Virtual Machine
  3. Generate Private Key
  4. Load Private Key in PuTTY
  5. Save Key as PuTTY’s own format (.pkk)
  6. Add Private Key to Putty

On Azure

create vm nva with ssh public key

Generate new key pair

An SSH key pair contains both a public key and a private key. Azure doesn’t store the private key. After the SSH key resource is created, you won’t be able to download the private key again

azure generates ssh keypair during vm creation in portal

Save Private Key to save it in PuTTY’s own format

save private key to save it in PuTTY's own format

click save private key to save it in PuTTY’s own format
click save private key to save it in PuTTY's own format

Add Key to PuTTY

Add SSH Key to Putty

Connect to VM with SSH using Putty
ssh to vm with privake key

login as: emcrsrvusr
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.13.0-1022-azure x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed May  4 08:59:32 UTC 2022

  System load:  0.08              Processes:             119
  Usage of /:   4.9% of 28.90GB   Users logged in:       0
  Memory usage: 3%                IPv4 address for eth0: 172.16.10.4
  Swap usage:   0%

1 update can be applied immediately.
To see these additional updates run: apt list --upgradable


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

emcrsrvusr@org-eunorth-production-nva-vm01:~$