Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » SSH into a VM created using Azure CLI or GUI
  • ansible business cards 1600x0 c default
    Kerberos error: Clock skew too great while getting initial credentials Windows Server
  • sdf
    What is GPO and how can it be launched in Windows Windows Server
  • Create AWS RDS instance
    How to create an Amazon Relational Database Service Instance AWS/Azure/OpenShift
  • How to manage user permission in AD and Synology
    Manage User Permission on Synology with Active Directory [Part 1] Reviews
  • Error 1069 Windows could not start
    Fix Error 1069: Windows could not start the Veeam backup service on local computer Backup
  • winn 11 3
    Enable HyperV on Windows: How to install Windows 11 on HyperV Windows
  • gitlabcomplete
    Install Docker Desktop and register GitLab-Runner with Docker-windows executor Containers
  • Retrict access to external storage
    Restrict access to removable Storage Drives [Part 2] Windows

SSH into a VM created using Azure CLI or GUI

Posted on 27/06/202214/03/2023 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on SSH into a VM created using Azure CLI or GUI
FEATURE-IMAGE

SSH is the Acronym for Secured Shell. SSH provides the needed credentials to connect to our virtual machines in Azure as it is a mechanism for using an encrypted connection to login into the host system remotely. It can connect to switches, routers, VMware, Linux, and any other server that supports SSH. Private and public keys are used for SSH connection. It is worth pointing out that, Public keys are stored on the Linux virtual machine, while the private key is used for confirming our identity. You may build virtual machines (VMs) in Azure that employ SSH keys for authentication using a secure shell (SSH) key pair. In this article, you will learn how to SSH into a VM created using Azure CLI or GUI.

You will learn how to create and utilize an SSH public-private key file pair for Linux virtual machines fast and easily. These steps may be completed using the Azure Cloud Shell, or a Linux VM. For the demonstrations, visual studio code was used. This article will teach you how to SSH into a virtual machine. Here are some similar guides: How to Generate SSH Key in Windows 10 and how to disable RC4 Cipher Algorithms support in SSH Server, and how to configure OpenSSH Server.

A virtual machine (VM) is similar to other real devices (laptop, smartphone, or server) on the network. It features a CPU, RAM, and disks for storing your files, as well as the ability to connect to the internet if necessary. VMs are conceived of as virtualization technology or software-defined computers within physical servers, existing solely as code, whereas the elements that make up your computer (called hardware) are actual and tangible. Here is how to install Windows Server 2019 on Virtualbox.

What is the purpose of a virtual machine?

Virtualization is a technique for establishing a software-based, or “virtual” version of a computer with a dedicated CPU, memory, and storage “borrowed” from a physical host machine (such as your personal computer) and/or a distant server (such as a server in a cloud provider’s datacenter). A virtual machine is a computer file (sometimes referred to as an image) that mimics the behavior of a real computer.

It can operate in a distinct computing environment in a window, frequently to run a different operating system—or even to serve as the user’s whole computer experience, as is usual on many people’s work PCs.

Since virtual machines are partitioned from the rest of the system, the software running inside it cannot interact with the host computer's principal operating system.

What are Virtual machines used for?

  • Creating and deploying cloud-based apps.
  • Trying out a new operating system (OS), which may include beta versions.
  • Creating a new environment to make running dev-test scenarios easier and faster for developers.
  • Creating a backup of your current operating system.
  • Installing an earlier OS allows you to access virus-infected files or use an old program.
  • Running software or applications on operating systems for which they were not designed.

What are the advantages of utilizing virtual machines (VMs)?

While virtual machines operate the same as computers with their own installed applications, they have the advantage of being completely separate from one another and from the physical host machine. A hypervisor, a virtual machine manager, is a piece of software that allows you to run multiple operating systems on different virtual machines at the same time. This allows you to run Linux VMs on a Windows OS, or an older version of Windows on a more recent Windows OS.

VMs are self-contained and they’re also very portable. A VM on one hypervisor can be moved to another hypervisor on a completely different machine almost instantly. Virtual machines have numerous advantages due to their flexibility and portability, including:

  • Financial Benefit: running several virtual environments on a single piece of technology reduces your actual infrastructure footprint dramatically. This helps you save money by reducing the number of servers you need to manage and saving on maintenance and power.
  • Precision and quickness: It’s far easier and faster to spin up a VM than it is to set up an entirely unique environment for your engineers. Virtualization speeds up the process of conducting development scenarios.
  • Reduced downtime: Because virtual machines are so portable and easy to migrate from one hypervisor to another on a separate system, they’re an excellent backup option in the event that the host goes down suddenly.

SSH into a VM created using Azure CLI or GUI

Part 1: Deploy your Virtual Machine using Azure CLI and SSH into it

The first thing to do would be to create a resource group and we can do this with a very easy command as shown below:

az group create --name junevm --location westus

the name of the resource group is junevm and the location we chose to have it is the west. You will need to start off by using the resource group when creating a Virtual machine. Else, we will get an error, which is why we needed to create it first.

rg
resource group created
az vm create --name techdirectarchive --resource-group junevm --location westus --image ubuntuLTS --admin-user raphael --generate-ssh-key
vm-run
vm is running

Things to take note of :

  1. We used the az command
  2. we gave our VM a name techdirectarchive with -name
  3. We included --resource-group in the command and used a previously created resource group junevm
  4. we added a location with –-location
  5. we added an image with the parameter --image and specified that we wanted UbuntuLTS
  6. If we are going to generate an ssh key, we need to include an admin-user we did with --admin-user raphael
  7. We added an ssh key with --generate-ssh-key

If we want to ssh into the newly created Virtual machine all we need to is: ssh admin-user@ipaddress or username@ipaddress

The admin user for the newly created VM is Raphael. The IP address is shown in the 20.253.144.106

ssh [email protected]
ssh

We have successfully ssh into the Virtual machine that we created using the Azure Cli command

Part 2: Deploy a Virtual Machine using Azure Portal GUI and SSH into it

We need to login into the Azure portal, search for VM in the search section and add the values in the box as shown below:

guivm-1
vm details

For SSH we need to take particular note of the administrator account details. We need to favor choosing SSH public key over password as the preferred authentication. We need to choose our keypair name also make sure that our selected inbound port is ssh

googtogo
admin details

We need to take note of where the keypair is downloaded to

generate_keypair
key pair generation

After the resource is created, we need to go to the search in the overview page we look for connect as shown below:

connect
connect
connect2
connect

After clicking on connect select SSH the one highlighted in green as shown in the picture above. you need to copy the command in option number 4.

SSH into a VM created using Azure GUI

command-to-run

let’s copy the command

ssh -i <private key path> [email protected]

The next thing to do is to search for the path to the key. You can do this by locating the public key you downloaded earlier. When you find it, right click on it and go to properties to show the location, you will need to append the public key name

pem-key
pem key

The next thing is to determine the path to the key. You can get that by right-clicking the pem file and checking the location section as shown below

path2key
path to key

You will append the public key file name together with its extension to the path to the key.

  • Path to key: C:\Users\Raph\Downloads
  • Public key name: azmoney.pem
  • The final path to key : C:\Users\Raph\Downloads\azmoney.pem

SSH into a VM created using Azure CLI

SSH command we copied from Azure portal:

ssh -i <private key path> [email protected]

Our final SSH command:

ssh -i C:\Users\Raph\Downloads\azmoney.pem [email protected]

Paste this command to the terminal.

techdirectarchive2

Summary

We were able to use Azure CLI commands to create a resource group and a virtual machine and with the format username@ipaddress we were able to SSH into the machine. We were able to create a virtual machine from the Azure portal.

In the admin section, we specified we wanted SSH as the preferred protocol, and we were prompted the download the SSH key that was later used to gain access to the VM.  The steps are all shown above.

I hope you found this blog post helpful. In this guide, you have learned how to SSH into a VM created using Azure CLI or GUI. Please let me know in the comment session if you have any questions.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux

Post navigation

Previous Post: How to Move OneDrive Folder to a different location in Windows
Next Post: How to install Golang on a Linux System

Related Posts

  • mailx
    [MAILX ERROR: STATUS=BOUNCED] Fixing Mailx error when sending emails from Command line Linux
  • trip wire feature
    How to install and configure Tripwire on Ubuntu Linux
  • Slide2 3
    Sudo Error on Ubuntu: Fixing ‘unknown uid 1000: Who are you?’ Linux
  • LINUX CONTAINERS
    How to install LXC/LXD for container management Linux
  • chamedk8s featured
    Install CNF Certified Kubernetes in AWS AWS/Azure/OpenShift
  • lampstack feature lamp stack ubuntu
    How to Install LAMP Stack on Ubuntu 18.04 Linux

More Related Articles

mailx [MAILX ERROR: STATUS=BOUNCED] Fixing Mailx error when sending emails from Command line Linux
trip wire feature How to install and configure Tripwire on Ubuntu Linux
Slide2 3 Sudo Error on Ubuntu: Fixing ‘unknown uid 1000: Who are you?’ Linux
LINUX CONTAINERS How to install LXC/LXD for container management Linux
chamedk8s featured Install CNF Certified Kubernetes in AWS AWS/Azure/OpenShift
lampstack feature lamp stack ubuntu How to Install LAMP Stack on Ubuntu 18.04 Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • ansible business cards 1600x0 c default
    Kerberos error: Clock skew too great while getting initial credentials Windows Server
  • sdf
    What is GPO and how can it be launched in Windows Windows Server
  • Create AWS RDS instance
    How to create an Amazon Relational Database Service Instance AWS/Azure/OpenShift
  • How to manage user permission in AD and Synology
    Manage User Permission on Synology with Active Directory [Part 1] Reviews
  • Error 1069 Windows could not start
    Fix Error 1069: Windows could not start the Veeam backup service on local computer Backup
  • winn 11 3
    Enable HyperV on Windows: How to install Windows 11 on HyperV Windows
  • gitlabcomplete
    Install Docker Desktop and register GitLab-Runner with Docker-windows executor Containers
  • Retrict access to external storage
    Restrict access to removable Storage Drives [Part 2] Windows

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,836 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

Active Directory AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.