Deploying Ubuntu Server in the Cloud: A Step-by-Step Guide

Introduction

Ubuntu Server is one of the most popular Linux distributions for cloud deployments, thanks to its stability, security, and extensive community support. Whether you’re setting up a virtual machine (VM) on AWS, Google Cloud Platform (GCP), or Microsoft Azure, Ubuntu Server provides a reliable foundation for hosting applications, databases, and other workloads.

In this guide, we’ll walk you through deploying Ubuntu Server on leading cloud platforms, including AWS, Google Cloud, and Azure. By the end of this article, you’ll understand the key steps involved in provisioning, configuring, and securing your Ubuntu Server in the cloud.


Why Deploy Ubuntu Server in the Cloud?

Deploying Ubuntu Server in the cloud offers several advantages:

  • Scalability: Cloud platforms allow you to scale resources up or down based on demand.
  • Global Availability: Deploy servers in multiple regions for low latency and high availability.
  • Cost Efficiency: Pay only for the resources you use, with flexible pricing models.
  • Automation: Use tools like Terraform, Ansible, or cloud-specific APIs to automate deployments.
  • Security: Cloud providers offer built-in security features, such as firewalls, encryption, and identity management.

Step 1: Choose a Cloud Platform

Before deploying Ubuntu Server, decide which cloud platform best suits your needs. Here are the key features of the top three providers:

Amazon Web Services (AWS)

  • Best for: Enterprises and developers requiring extensive service options.
  • Key Features: EC2 instances, S3 storage, security groups, and auto-scaling.
  • Pricing: Pay-as-you-go with free tier options for beginners.

Google Cloud Platform (GCP)

  • Best for: Data-intensive workloads and machine learning applications.
  • Key Features: Compute Engine, Kubernetes Engine, and BigQuery.
  • Pricing: Transparent pricing with sustained-use discounts.

Microsoft Azure

  • Best for: Businesses already using Microsoft technologies like Windows Server and Active Directory.
  • Key Features: Virtual Machines, Azure Active Directory, and hybrid cloud support.
  • Pricing: Competitive pricing with hybrid benefits for Windows licenses.

Step 2: Provision an Ubuntu Server

2.1 Deploying on AWS

Step 1: Log in to AWS Management Console

Visit AWS Management Console and log in with your credentials.

Step 2: Launch an EC2 Instance

  1. Navigate to EC2 under the “Compute” section.
  2. Click on Launch Instance.
  3. Choose an Ubuntu Server AMI (Amazon Machine Image), such as Ubuntu Server 22.04 LTS.

Step 3: Configure Instance Details

  1. Select the instance type (e.g., t2.micro for free tier eligibility).
  2. Configure network settings, such as VPC and security groups.
  3. Add storage (default is 8 GB, but you can increase it based on your needs).

Step 4: Add Key Pair

Create or select an SSH key pair to securely connect to your server.

Step 5: Launch the Instance

Click Launch and wait for the instance to be ready.

Step 6: Connect to Your Instance

Use SSH to connect:

ssh -i <your-key.pem> ubuntu@<instance-public-IP>  


2.2 Deploying on Google Cloud

Step 1: Log in to Google Cloud Console

Visit Google Cloud Console and log in.

Step 2: Create a Virtual Machine

  1. Navigate to Compute Engine > VM Instances.
  2. Click Create Instance.

Step 3: Configure VM Details

  1. Choose a name for your instance.
  2. Select a region and zone based on your location.
  3. Pick an Ubuntu Server image (e.g., Ubuntu 22.04 LTS).

Step 4: Configure Machine Type

Select the machine type (e.g., e2-micro for free tier eligibility).

Step 5: Add SSH Key

Add your public SSH key under Security settings.

Step 6: Create the Instance

Click Create and wait for the VM to be provisioned.

Step 7: Connect to Your Instance

Use the gcloud CLI or SSH to connect:

gcloud compute ssh <instance-name> --zone=<zone>  


2.3 Deploying on Azure

Step 1: Log in to Azure Portal

Visit Azure Portal and log in.

Step 2: Create a Virtual Machine

  1. Navigate to Virtual Machines.
  2. Click Create > Virtual Machine.

Step 3: Configure VM Details

  1. Choose a subscription and resource group.
  2. Select an Ubuntu Server image (e.g., Ubuntu Server 22.04 LTS).
  3. Pick a VM size (e.g., B1s for cost efficiency).

Step 4: Configure Authentication

Select SSH public key and provide your public key.

Step 5: Networking

Configure inbound port rules (e.g., allow SSH on port 22).

Step 6: Review and Create

Click Review + Create and wait for the VM to be deployed.

Step 7: Connect to Your Instance

Use SSH to connect:

ssh -i <your-key.pem> azureuser@<instance-public-IP>  


Step 3: Post-Deployment Configuration

3.1 Update and Upgrade the Server

After connecting to your server, update and upgrade the system:

sudo apt update && sudo apt upgrade -y  

3.2 Configure Firewall Rules

Set up a firewall using ufw to secure your server:

sudo ufw allow OpenSSH  
sudo ufw enable  

3.3 Install Essential Packages

Install packages commonly used for server management:

sudo apt install -y curl wget git build-essential  


Step 4: Securing Your Ubuntu Server

4.1 Disable Root Login

Edit the SSH configuration file to disable root login:

sudo nano /etc/ssh/sshd_config  

Find and set:

PermitRootLogin no  

Restart SSH:

sudo systemctl restart sshd  

4.2 Enable Automatic Security Updates(optional based on your requirement)

Install and configure unattended-upgrades:

sudo apt install unattended-upgrades  
sudo dpkg-reconfigure unattended-upgrades  


Step 5: Scaling and Monitoring

5.1 Auto-Scaling

For AWS, use Auto Scaling Groups to dynamically scale resources based on demand.

For GCP, configure Instance Groups for scaling.

For Azure, use VM Scale Sets to manage scaling.

5.2 Monitoring

Use cloud-native tools to monitor your server:

  • AWS: Use CloudWatch for metrics and logs.
  • GCP: Use Stackdriver for monitoring and alerts.
  • Azure: Use Azure Monitor for insights and diagnostics.

Conclusion

Deploying Ubuntu Server in the cloud is a straightforward process, whether you’re using AWS, Google Cloud, or Azure. In this guide, we covered:

  • Choosing the right cloud platform for your needs.
  • Provisioning an Ubuntu Server on AWS, Google Cloud, and Azure.
  • Configuring and securing your server after deployment.

By following these steps, you can set up a robust Ubuntu Server environment for hosting applications, databases, or other workloads. With cloud-native tools and automation capabilities, managing your server becomes efficient and scalable.

Up Next:
We will talk about Automating Ubuntu Server Setup with Ansible: A Practical Guide in next article, please stay tuned.

Leave a Comment