DEV Community

Cover image for Mastering Azure: Deploying a Linux Virtual Machine and Connecting via SSH
Maxwell Ugochukwu
Maxwell Ugochukwu

Posted on

Mastering Azure: Deploying a Linux Virtual Machine and Connecting via SSH

Azure, Microsoft's cloud platform, offers a diverse ecosystem that includes robust support for Linux virtual machines (VMs). In this step-by-step guide, we'll explore how to deploy a Linux VM in Azure and connect to it using SSH, making it a breeze to harness the power of Linux in the cloud.

Prerequisites

Before we embark on our Azure Linux VM journey, make sure you have the following essentials:

Azure Account: You'll need an Azure account to access the Azure portal. If you don't have one, you can sign up for a free trial.

SSH Client: Ensure you have an SSH client installed on your local machine. On Windows, you can use tools like PuTTY or the built-in OpenSSH client. On macOS and Linux, the OpenSSH client is pre-installed.

Step 1: Sign in to Azure Portal

Start by logging in to the Azure portal using your Azure account credentials.

Image description

Step 2: Create a Linux Virtual Machine

In the Azure portal, click on "Create a resource."

Image description

Search for "Ubuntu Server" or your preferred Linux distribution in the marketplace.

Image description
Select the version you want and click "Create."

Image description

In the "Basics" tab of the virtual machine creation wizard, provide the following details:

Subscription: Choose your Azure subscription.

Image description
Resource group: Create a new one or use an existing group.

Image description

Image description

Virtual machine name: Give your VM a unique name.

Image description

Region: Select the Azure region where your VM will be hosted.

Image description

Image: Choose the Linux distribution and version.

Image description

Size: Pick an appropriate VM size based on your needs.

Image description
In the "Administrator account" section, provide a username and secure password for your VM's administrator account. Alternatively, you can use SSH keys for authentication but here we use username and password.

Image description

In the "Inbound port rules" section, ensure that "SSH (22)" is allowed for connecting via SSH.

Image description

Review your settings and click "Next."

Complete the remaining steps (disks, networking, management, and advanced) based on your requirements. You can typically accept the default settings for a basic VM setup, click "Review + Create.".

Image description

Review your configuration, and click "Create" to provision your VM.

Image description

Step 3: Connect via SSH

After Azure deploys your VM, navigate to your VM's details in the Azure portal.

Image description

Click on "Connect" under the Settings blade.
Image description

Under the "Connect" menu, you'll find instructions for connecting to your VM. It should look something like this:

shell
Copy code
ssh username@your-vm-ip-address
Replace username with your VM's username and your-vm-ip-address with the VM's public IP address.

Open your terminal or SSH client and paste the SSH command. Press Enter.

Image description
You'll be prompted to enter the password for the user you specified during VM creation. If you're using SSH keys, you may be prompted for the passphrase associated with the private key but here we use password.

Image description
Voilà! You're now connected to your Linux VM in Azure. You can start using it just like a local Linux machine.

Image description

From here, you can manage your Azure Linux VM as needed. You can install software, configure services, and host web applications, all within your Azure environment.

Conclusion
Deploying a Linux VM in Azure and connecting to it via SSH is a valuable skill for developers, sysadmins, and anyone working in the cloud. It empowers you to leverage Azure's infrastructure while harnessing the capabilities of Linux. Whether you're running web servers, databases, or development environments, Azure offers a robust platform for all your Linux needs. So go ahead, explore, experiment, and make the most of Azure's Linux-friendly ecosystem!

Top comments (0)