How to Create and Deploy a Linux Virtual Machine in Azure with SSH and Password Access
Table of contents
- Why Deploy a Linux VM in Azure?
- Step-by-Step Guide
- Step 1: Login to Azure Portal
- Step 2: Navigate to Virtual Machines
- Step 3: Configure Basic Settings
- Step 4: Set Up Authentication For SSH:
- Step 5: Configure Inbound Port Rules
- Step 6: Configure Disk
- Step 7: Configure Networking
- Step 8: Management, Monitoring, Advanced and Tags Options (Optional)
- Step 9: Review and Create
- Step 10: Connect to Your Linux VM
- Connect to Linux VM Using Password:
- Final Thought
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
Visit the Azure Portal.
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:
- Enter the Username
- Choose your desire SSH public key source (e.g., Generate new key pair).
- Choose your desired SSH key type and enter a key pair name, or use the default auto-generated key.
For Password:
Enter the Username.
Create a strong Password that meets Azure's complexity requirements.
Step 5: Configure Inbound Port Rules
- 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
- OS disk size: Select the disk size for your Virtual Machine
- OS disk type: Choose your desired OS disk type, such as Premium SSD (Locally-Redundant Storage).
- Choose to automatically delete a disk when the associated virtual machine is deleted and Choose a Key management
Step 7: Configure Networking
- Virtual Network: Use an existing one or create a new virtual network.
- Subnet: Select the default subnet or create a custom one.
- Public IP Address: Enable and create a new public IP address.
- 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.
- Select your preferred load balancing option.
Step 8: Management, Monitoring, Advanced and Tags Options (Optional)
Choose to enable or disable system-assigned managed identity.
Configure additional monitoring options as needed, or leave them at their default settings.
- Configure monitoring, Advanced, and Tags options as desired, or leave them at their default settings.
Step 9: Review and Create
- Click Review + Create to validate the configuration.
- 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:
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
- When prompted "Are you sure you want to continue connecting", type "yes" and enter to proceed.
- Connection established! The screenshot below confirms successful SSH connection to the VM
- Run the command "hostname" and press Enter to display your VM's hostname.
- 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:
- Open a PowerShell terminal and type: ssh username@IP-Address and press enter.
- When prompted "Are you sure you want to continue connecting", type "yes" and enter to proceed.
- Enter your password and press Enter. Note that your password will not be visible on the screen for security purposes.
- Connection established! The screenshot below confirms successful password connection to the VM
- Run the command "hostname" and press Enter to display your VM's hostname
- 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!