How to Create and Deploy a Linux Virtual Machine in Azure with SSH and Password Access

How to Create and Deploy a Linux Virtual Machine in Azure with SSH and Password Access

Creating and deploying a Linux Virtual Machine (VM) in Microsoft Azure with SSH and password access is a straightforward process. This guide walks you through each step, ensuring your VM is configured securely and effectively.

Why Deploy a Linux VM in Azure?

Azure provides a reliable and scalable platform for deploying Linux VMs, offering benefits such as:

  • Access to diverse Linux distributions.

  • Integration with Azure services for enhanced functionality.

  • High availability and global reach.

Step-by-Step Guide

Step 1: Login to Azure Portal

  1. Visit the Azure Portal.

  2. Log in with your Microsoft Azure credentials.

Step 2: Navigate to Virtual Machines

1. From the homepage, click 'Virtual Machines' under Azure Services.

2. Select + Create and click on Virtual Machine.

Step 3: Configure Basic Settings

Fill in the following details:

  • Subscription: Choose your Azure subscription.

  • Resource Group: Select an existing resource group or create a new one.

  • Virtual Machine Name: Enter a name

  • Region: Choose the desired region (e.g., (Europe) UK South).

  • Availability Options: Select your desire availabilities option (e.g, Availability Zone).

  • Availability zone: Select one or multiple zones.

  • Security type: Choose your desire security type (e.g, Trusted launch virtual machines)

  • Image: Pick a Linux distribution (e.g., Ubuntu 20.04 LTS).

  • Size: Choose a VM size (e.g., Standard B1s).

  • Authentication Type: Choose SSH public key or Password.

Step 4: Set Up Authentication For SSH:

  1. Enter the Username

  1. Choose your desire SSH public key source (e.g., Generate new key pair).

  1. Choose your desired SSH key type and enter a key pair name, or use the default auto-generated key.

For Password:

  1. Enter the Username.

  2. Create a strong Password that meets Azure's complexity requirements.

Step 5: Configure Inbound Port Rules

  1. Allow selected ports for Public inbound ports and select SSH (22) and HTTPS (443) for inbound ports. then click “Next: Disks”

Step 6: Configure Disk

  1. OS disk size: Select the disk size for your Virtual Machine

  1. OS disk type: Choose your desired OS disk type, such as Premium SSD (Locally-Redundant Storage).

  1. Choose to automatically delete a disk when the associated virtual machine is deleted and Choose a Key management

Step 7: Configure Networking

  1. Virtual Network: Use an existing one or create a new virtual network.

  1. Subnet: Select the default subnet or create a custom one.

  1. Public IP Address: Enable and create a new public IP address.

  1. Choose if you want security rule for "NIC network security group" to be None, Basic or Advanced, allow Public inbound ports, and select inbound ports.

  1. Select your preferred load balancing option.

Step 8: Management, Monitoring, Advanced and Tags Options (Optional)

  1. Choose to enable or disable system-assigned managed identity.

  2. Configure additional monitoring options as needed, or leave them at their default settings.

  1. Configure monitoring, Advanced, and Tags options as desired, or leave them at their default settings.

Step 9: Review and Create

  1. Click Review + Create to validate the configuration.

  1. For SSH authentication, after you click "Create", a "Generate new key pair" prompt will appear. Click "Download private key and create resource” and save the file.

3. Deployment completed

Step 10: Connect to Your Linux VM

Using SSH:

  1. Open a PowerShell terminal and type: ssh -i Private Key username@IP-Address and enter

    a. Make sure to Use the path to the private key downloaded earlier.

b. Use the Public IP Address associated with your VM

  1. When prompted "Are you sure you want to continue connecting", type "yes" and enter to proceed.

  1. Connection established! The screenshot below confirms successful SSH connection to the VM

  1. Run the command "hostname" and press Enter to display your VM's hostname.

  1. Run the command "sudo su -" and press Enter to switch to the root user, granting elevated privileges to create and execute commands on your VM.

Connect to Linux VM Using Password:

  1. Open a PowerShell terminal and type: ssh username@IP-Address and press enter.

  1. When prompted "Are you sure you want to continue connecting", type "yes" and enter to proceed.

  1. Enter your password and press Enter. Note that your password will not be visible on the screen for security purposes.

  1. Connection established! The screenshot below confirms successful password connection to the VM

  1. Run the command "hostname" and press Enter to display your VM's hostname

  1. To switch to the root user run the command "sudo su -” and press Enter. This will grant you elevated privileges to create and execute commands on your VM.

Final Thought

Deploying a Linux VM in Azure with SSH and password access is a seamless process that ensures you have a flexible, scalable, and secure environment for your workloads. By following this guide, you can create a VM tailored to your requirements while leveraging Azure’s robust infrastructure. If you have any questions or need further assistance, feel free to drop a comment below. I will happily respond!