Azure Virtual machines (VMs) can be created through the azure portal. The Azure portal is a browser-based user interface to create Azure resources. This article shows you how to use the Azure portal to deploy a Linux Virtual Machine (VM)using Public key Authentication.
Step 1: Sign in to Azure Portal
- Open your web browser and access the Azure Portal.
- Sign in using your Azure account credentials
Step 2: Create a Resource Group (if not available or use an existing one)
- Resource Group: If a suitable resource group for your VM deployment does not exist, create a new one.
Click on resource groups in the upper left corner of the Azure portal.
Click + Create to create a new resource group.
Assign a Name for your resource group, choose a Subscription, and select a Region.
Click Review + create and then Create to create the resource group.
Step 3: Create a Virtual Machine
- Create VM: Now create a new Virtual Machine. There are several methods of searching for virtual machine:
In the Azure portal, click + Create a resource at the top-left corner.
Search for Virtual Machine and click Create.
Alternatively, you can:
- In the search bar of the home page, type 'Virtual Machines' and select Virtual Machines **under **Services
- On the Virtual Machines page, select Create, this will open the Create a virtual Machine page
1. Configure the Basics
- Subscription: Select the correct subscription you want to use
- Resource group: Select the resource group you have created or create a new one if you have not (another way of creating resource group)
Virtual machine name: Specify a name for your VM
Region: Choose the region where you would want to deploy your VM
Availability options: Choose any if needed
Image: Select a Linux distribution (Ubuntu Server from the list)
Size: Choose a VM size based on what you require.
- Administrator Account
Authentication type: Select SSH public key
Username: Choose a username
SSH public key source: Keep the default setting of Generate new Key pair
Key pair name: Name mostly pops up on its own
Public inbound ports: Select Allow selected ports
Select inbound ports: Choose HTTP (80) and SSH (22) or as required.
3.Disks and other settings:
Configure the disk, networking, management, and monitoring options according to your requirements.
4. Review + Create:
Review your VM configuration
Click create to start deploying your VM after validation passed.
Step 4: Connect to your Linux VM
SSH Connection through PowerShell: Once the deployment is complete, you can connect your VM to SSH through PowerShell.
Navigate to your VM in the Azure portal.
Under Settings, click on Connect to get connection information.
Using PowerShell: This can be done with your Laptop.
Open PowerShell on your physical computer
Use this command to connect to your Linux VM using SSH:
ssh username@public-ip-address
whereby, you replace the 'username' with the username you specified during the creation of VM and 'public-ip-address' with the public address of your VM.
- If prompted to confirm the connection, type 'yes' and press Enter.
Step 5: Clean Up Resources
After you've finished using your VM, it's a good practice to clean up resources to avoid unnecessary charges:
In the Azure portal, navigate to your resource group containing the VM.
Select the resource group and click Delete.
- Follow the prompts to confirm deletion. This action will delete all resources within the resource group, including the VM, disks, and network interfaces.
In conclusion, setting up and deploying a Linux VM on Azure, along with connecting to it via SSH using PowerShell, offers a versatile and potent environment for development and testing purposes. It's essential to regularly tidy up resources to control costs and uphold an organized Azure setup. Azure's user-friendly interface and comprehensive management tools simplify the process of efficiently handling your virtual machines.
Top comments (2)
This is a Great tutorial, Adah Okwara. Creating and connecting to a Linux virtual machine on Azure portal using public key authentication, with clear and concise steps and helpful explanations.👌👏
It was very enlightening, quite detailed, and great to learn from. keep it up.