DEMO: Deploying and Connecting to a Linux Virtual machine via the Azure Portal
Start course
1h 27m

This course will give you a basic understanding of Azure virtual machines (VMs) and how you can use them in your Azure environments.

The course begins by introducing you to Azure VMs and what resources are necessary to deploy them, before moving onto pricing and the different virtual machine options available. Next, the course explores availability sets and availability zones and gives a demonstration that shows you how to create an availability set using the Azure portal.

The course shows how to deploy both Windows and Linux virtual machines, and you'll get a demonstration of how to deploy and connect to each. Rounding off the course is a section on basic management tasks; you’ll learn how to start, stop, restart, redeploy, and resize virtual machines.

This course is packed full of real-world demonstrations from within the Azure portal to give you first-hand experience of how to get the most from Azure Virtual Machines.

For any feedback you may have relating to this course, please contact us at

Learning Objectives

  • Gain a foundational understanding of Azure virtual machines, their features, and their pricing
  • Learn how to set up availability sets
  • Learn how to create and connect to both Windows and Linux virtual machines with Azure
  • Learn how to manage your Azure VMs including starting, stopping, restarting, redeploying, and resizing VMs

Intended Audience

This course is intended for anyone who is interested in learning about the basics of Azure virtual machines.


To get the most from this course you should have a basic understanding of Microsoft Azure and of the Azure portal.


Hello and welcome back. In the previous lesson, we walked through the process of creating a Windows virtual machine. What we're going to do here is deploy a Linux VM. Now, what we're not going to do in this demonstration is walk through all of the individual settings, like we did in the Windows VM demonstration, because, frankly, I've already shown them to you. But what I will do is point out the differences along the way.

One thing we are going to focus on is the authentication method for this VM, because instead of using RDP, we're going to use SSH. And as part of that authentication process, we're going to set this VM up so that it can use SSH keys for authentication versus a username and password. Part of that process will require us to use PuTTYgen to create the SSH keys, and then we'll have to use PuTTY to connect to the VM using those SSH keys.

So, let's jump in here. On the screen, I'm logged into my Azure Portal, and I'm in my VM course resource group, like I was in the previous demonstration. You can see here we have our VMO 1, that eventually spun up. And if I select it here, you can see that it stopped.

I don't leave my VMs running because it gets expensive, especially when I'm not doing anything with them. So, we'll go back out to our VM course resource group here. And what we'll do is we'll deploy our Linux VM, just like we did for our Windows VM. After clicking Add there, we can either search the marketplace or we can select the Ubuntu server 1804 LTS. We'll go ahead and deploy Ubuntu server.

You can see immediately that the screens are almost identical to that of the Windows VM. So, we're going to bypass a lot of these options, kind of skip over them. You've already learned this stuff in the last demonstration, so I don't want to bore you by going through them all over again. So, let's kick things off.

We're going to deploy into the lab subscription and the VM course resource group. We'll call this new VM VM02. And we will deploy into central US, along with all of my other resources. And for this demonstration, I'm going to leave the availability options set to no infrastructure redundancy required.

If I select the drop down, I do have the option of availability zone or set. But since I already showed you how to add this to an availability set, we'll leave this set to no infrastructure. We can see our image is Ubuntu server, and we will not be using a spot instance.

For this demonstration, we'll leave the default size alone, which is one CPU and three and a half gig of RAM, but down here in administrator account, this is where we're going to make some changes. You can see we have two different authentication types. We can use an SSH public key or a password.

If I select password here, I'm prompted, just like I was for a Windows VM, to enter a username and password for the administrator account. What we're going to do though is make things fun by using an SSH public key. By selecting SSH public key, we're going to use a key to authenticate.

Now, even though we specify SSH public key, we still need to provide a username. And in this SSH public key box, we need to paste in a public key. If we hover over the icon here next to public key, we can see that we need to provide an RSA public key in either a single line format or in multi line PEM format. We can generate SSH keys by using the SSH key Gen on Linux and OSX, or via PuTTYgen on Windows.

Since I'm running Windows, we're going to use PuTTYgen. So, let me drag my PuTTYgen key generator over here. And don't worry, at the end of this demonstration, I'll provide a link that you can use to download PuTTYgen. It's a free tool. So, what I'm going to do here is I'm going to use my PuTTY key generator to create a public key and private key that we'll use to authenticate to our VM later on.

Now, if we hover over the icon here next to public key, we can see that we need to provide an RSA key. So, to generate our RSA key here, we're going to ensure that the type of key to generate is set to RSA, and then we'll click Generate. What we need to do then is move our mouse around here in this box. And what that does is generates a key based on those random movements. So I have my public key here that's been generated based on my mouse movements. This public key here is what we're going to paste into this SSH public key box. But before I do that, I want to protect my keys with a passphrase, and then I want to save both the public and private keys so I don't lose them.

So, we'll go ahead and create a passphrase to protect my key. And we'll confirm it. And then, what I'll do here is I'll save my public key. Now, what I also want to do is save the private key. So, now that I have my keys saved, what we'll do here is we'll select my public key and we will paste it into our public key box.

So, now that we have our username and public key created, what we'll do here is leave the inbound port rules at their defaults. You can see here, we have the notice about open access just like we did with RDP, but in this case, we're allowing SSH. Let's go ahead and click forward to disks. And we can see the disks page is the same as it was for our Windows VM.

So, we're not going to do anything here. For this demonstration, I am not going to create a data disc. We'll leave our OS disk type at premium SSD for this demonstration, and then we'll go ahead and click into networking. The networking page is also the same as it was for the Windows VM. We need to define our network information, our NIC and inbound information. And then, our load balancing options.

You can see here that the virtual network has already defaulted to the virtual network that was created when we created the Windows VM. It also defaulted to the default subnet for that virtual network. So, we'll leave those alone. And as it did with the Windows VM, it's going to create a new public IP for me so I can connect to it over the internet. We'll leave the security information alone at its defaults. And this particular VM doesn't support accelerated networking.

So, the accelerated networking option is set to off. Like we did with the Windows VM, we'll leave load balancing turned off. And we'll go to management. And we can see the management page is the same as it was for Windows. There is nothing new here. We can see for our diagnostic storage account that it's defaulting to our VM course diag storage account that we created when we created the Windows VM as well.

This is because this VM course diag storage account is in the same resource group as the VM we're creating. We'll go ahead and leave system-assigned managed identity turned off, as well as login with Azure Active Directory credentials.

So, let's go ahead and click Advanced. And we can see the advanced page is basically the same as well as it was for Windows. But I do wanna point out here, if I select an extension here under extensions, the list of extensions I get are all for Linux machines. I'm not going to get Windows extensions here. Everything I see here is going to be for Linux.

When I deployed the Windows VM, I got windows resources. So we're not going to install any here. But what I do want to point out is that cloud-init, while it wasn't germane to a Windows VM, it is germane to a Linux VM. If we click on Learn More here and open it up in a tab, we can see all the information about cloud-init. We're not going to get into cloud-init here because it's frankly a little more advanced than what the intent of this course is, but essentially what this cloud-init is used for is to configure a virtual machine, or even virtual machine scale sets, as you see here, at the time of provisioning. We can see that cloud-init configurations are run on first boot once all of the VM resources have been provisioned.

We're not going to use cloud-init to do any configuration, but I wanted to show you that this exists, and you should probably check it out, just to read up on it so you understand it. But as far as basic deployment of a VM, this isn't critical to know. So, I'm going to close this out and go back in. We are not going to use host groups, nor are we going to use proximity placement groups. We talked about these earlier, so I'm not going to go over them again. And we'll deploy a Gen 1 VM here.

I should point out the note at the bottom here, which is actually kind of interesting. The Gen 2 VMs do not support some Azure platform features, including Azure disk encryption, which is kind of surprising.

We're deploying our VM in a Gen 1 fashion. So, we'll go ahead and click Next through tags. And we'll do the same thing we did for Windows. We'll tag it with a department tag. And we'll call it finance. If we click review and create here, we get the validation passed banner here. And again, we get another warning that we have SSH open to the internet, giving us the whole speech that we shouldn't do that, that's fine.

Once this validation completes, we can scroll down to the bottom and click Create. And what this will do is deploy our new VM. We can see that our deployment has completed. And we'll go ahead and click Go To Resource here. From our overview page here we can see that our VM is running.

So, at this point let's connect to our virtual machine over SSH using PuTTY. Let me drag my PuTTY Client over. And again, I'll provide you with a link at the end that you can use to download PuTTY and PuTTYgen.

Now, from my PuTTY screen here, what I need to do is plug in the IP address of the VM I'm trying to connect to. We're going to connect over Port 22 and use SSH. Now, before we connect to our VM we need to expand SSH down here at the bottom, and then go into the Off page. Since we're using SSH keys to authenticate, I need to browse for the private key that matches the public key that we created for the VM. And this is the private key that I saved off earlier. So, we'll browse, and we'll go into keys here, and there is my private key that I saved earlier. At this point, I can click Open.

Now, let me drag over the security alert I got here. What PuTTY is doing is it's telling me that the host key on the server hasn't been cached in my local registry. This is essentially a security key saying hey, do you know what you're connecting to and are you sure that's what you want to do? And basically it tells me here if I trusted click Yes, if not click No. Well, I trust it because it's the VM that I deployed. So, we'll click Yes. And then, what I'll do is I'll drag over the PuTTY screen.

Now, I'm being prompted to login as, so I need to provide my username. When I press enter here, it's going to authenticate with the public key, and then it's going to prompt me for that passphrase that I configured.

Remember, I had to create that passphrase in PuTTYgen when I created the key. That's what it's asking for here. And at this point, we can see that I'm logged into VMO 2 as VM Admin. So, with that, I've created a VM that runs Linux. I've configured it to use SSH keys for authentication. I've created the SSH key pair. And then, I've used PuTTY to log in via SSH using that key pair.

So at this point, you should now know how to provision a basic Linux VM, how to configure authentication through SSH, and how to use PuTTY to connect over SSH.

About the Author
Learning Paths

Tom is a 25+ year veteran of the IT industry, having worked in environments as large as 40k seats and as small as 50 seats. Throughout the course of a long an interesting career, he has built an in-depth skillset that spans numerous IT disciplines. Tom has designed and architected small, large, and global IT solutions.

In addition to the Cloud Platform and Infrastructure MCSE certification, Tom also carries several other Microsoft certifications. His ability to see things from a strategic perspective allows Tom to architect solutions that closely align with business needs.

In his spare time, Tom enjoys camping, fishing, and playing poker.