In this blog, we are going to discuss how to create an Ubuntu Azure Virtual Machine and connect to it.
The following sections have been covered in this blog:
- Azure Virtual Machines?
- Creating An Ubuntu Virtual Machine
- Connecting To Ubuntu Virtual Machine
This blog talks about technologies that are part of the Azure Cloud Administration. If it’s something in which you have an interest or you want to learn it then you can visit our previous blog to know more about the [AZ-104] Microsoft Azure Administrator certification.
Azure Virtual Machines
Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. Typically, you choose a VM when you need more control over the computing environment than the other choices offer. This article gives you information about what you should consider before you create a VM, how you create it, and how to connect to it.
An Azure VM gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it. However, you still need to maintain the VM by performing tasks, such as configuring, scale-up/down the machine, and installing the software that runs on it.
Azure virtual machines can be used in various ways. Some examples are:
- Development and test – Azure VMs offer a quick and easy way to create a computer with specific configurations required to code and test an application.
- Applications in the cloud – Because demand for your application can fluctuate, it might make economic sense to run it on a VM in Azure. You pay for extra VMs when you need them and shut them down when you don’t.
- Extended datacenter – Virtual machines in an Azure virtual network can easily be connected to your organization’s network.
The number of VMs that your application uses can scale up and out to whatever is required to meet your needs.
- An Azure Cloud Account ( you can learn how to create one from our previous blog here.)
- Access to an SSH client: for this tutorial, we will be using Putty and Putty Key Generator installed on our Windows computer for accessing our Ubuntu Virtual Machine.
Creating An Ubuntu Virtual Machine
Step 1: In the Azure portal, search for Virtual Machine and select Virtual Machine.
Note: Please make sure you have a subscription before doing all this. If you created a free account for the first time, you’ll already have a FREE TRIAL subscription for 1 month.
Step 2: Select Add.
Step 3: Enter the following values:
- Subscription: Select your Azure subscription.
- Resource group: Enter a new resource group name.
- Virtual Machine name: It should be a unique name throughout the Azure network.
- Region: Select an Azure location, such as Western India, Central US, etc.
- Authentication Type: SSH Public Key
- SSH Public Key Source: Generate new key pair
- Select Inbound Ports: SSH (22), this is the port that we will be using to connect to our Virtual Ubuntu Machine.
- Select the Username and Key name as required and note them down as we will need them later.
- Once done, click on Next: Disks >
Step 4: Select the type of disk you want to use. Click Next.
Step 5: Configure Networking
- Virtual Network: Create a new one or use your existing Network.
- Select Inbound Ports: SSH(22), This allows Port 22 to be opened in your Virtual Network for incoming traffic and will enable us to connect to our Virtual Machine inside our Virtual Network.
- Leave everything else as default and click next to go to the Management Section.
Step 6: Management
Leave all options as default and click on next to go to the Advanced Section.
Step 7: Advanced Configuration
Add any custom data you want to run when the VM is being created or leave all options as default and click on next to go to the Tags Section.
Step 8: Tags Configuration
Add any descriptive tags you would like to put to identify your VM at a later stage or leave Options at default and click on next to review and create your Virtual Machine.
Step 9: Review your settings and make any changes if required and select Create. It takes a few seconds to create a VM.
Step 10: SSH Keys
- After you click on Create Azure will create an SSH Key Pair that we will be using to connect to our VM later. Make sure to download the private key and keep it somewhere safe.
- Azure does not store your private key and this is the only instance when you will be able to access your private key from Azure.
Connecting to Ubuntu Virtual Machine
As we have configured our VM to be accessible via SSH we will be using the PuTTY SSH client on our Windows machine.
You can download and install PuTTY from its official website. Simply select Download Putty and choose the appropriate installation file (32-bit or 64-bit as per your system) from the choices shown.
Step 1: Converting our Private key into the proper extension.
The Azure private key we downloaded is in the (.pem) format, for using it with PuTTY we need to convert it into the (.ppk) format.
- Open PuTTYgen, an application automatically installed alongside PuTTY.
- Select load an existing private key. (make sure to select All files option while browsing to your Azure Key)
- You will get an Operation successful message if the key was imported correctly.
- Click on Save Private Key to save the key in a PuTTY usable format.
- you can optionally set a password to be used with this key for further security but for this tutorial, we will be skipping that.
Step 2: Getting the SSH connection information.
- Go to the VM dashboard
- Select your VM
- Note the public IP address.
Note: every time the VM is restarted, this IP will be Different, unless you have an Elastic IP configured for your VM.
Step 3: Open the PuTTY installation on your Windows Machine.
- Enter the Host Name details in the following format: <Username of VM>@<Public IP of VM>
- Make sure Port is 22.
- The connection type is SSH.
Step 4: Inserting our SSH key for authentication.
- Expand the SSH option under Connection in the sidebar.
- Select Auth, Do not expand it.
- Leave all options at default settings and under private key file for authentication, browse to the Private Key we had created from PuTTYgen earlier.
- Click Open.
- Click yes in the security alert box to allow the remote connection.
If all the steps were done correctly then the connection will be successful and you will be logged into your Ubuntu Virtual Machine.
- [AZ-900] Microsoft Azure: Resource Group, Resource Manager & ARM Template
- Azure Proximity Placement Groups | When To Use And What To Expect
- [AZ-104] Microsoft Azure Administrator Certification Exam: Everything You Need To Know
Next Task For You
Begin your journey towards becoming a Microsoft [AZ-104] Certified Azure Administrator by joining our FREE Masterclass. We strongly recommend gaining knowledge from both AZ-103 and AZ-104 in order to be an effective Azure Administrator. Our course covers both AZ-103 and AZ-104 certification.
Click on the below image to register for the Free Class NOW!