[Linux] How to login Azure Linux VM’s using SSH key pair

This post is for Linux newbies trying to figure out SSH way login to Azure Linux VM. I am following the steps explained here. Had seen many times our windows users struggle to get this right at first shot. Hope the below screenshots are clear to follow and achieve easy logon. Ps note, there are many ways to get this done but I felt this as the quick way to get it right without jumping between tools/sites.

Step 1: I am using WSL but you can try Git Bash or bitvise or Putty or Tux vm or any other SSH client of your choice.

image

Pls note down the Key passphrase safely. This is required when we SSH to Linux VM from $ terminal.

Step 2: You would see the public and private keys generated at the path ~/.ssh. Cat out the id_rsa.pub file to grab the public key which is required when creating Azure Linux VM.

image

Step 3: Paste the above Public key at the time of VM creation in portal or CLI

image

Step 4: Once the VM is created, copy the SSH command to logon

image

Step 5: Go back to the your favorite SSH client and run the above copied command. Pls note, it will prompt for the passphrase which you have to enter now. On success, you would see your remote machine terminal.

image

Let me know if you see this helps you in some way.

Happy learning !