Last modified: March 23, 2026

This article is written in: πŸ‡ΊπŸ‡Έ

Deploying CentOS VM on Digital Ocean

Digital Ocean provides cloud-based virtual machines called Droplets that let you deploy and manage CentOS servers. The overall flow looks like this:

+-------------+         SSH (port 22)         +----------------------+
 |             | ---------------------------->  |                      |
 | Local       |                                |  Digital Ocean       |
 | Machine     |                                |  Droplet (CentOS)   |
 |             | <----------------------------  |                      |
 +-------------+        Response               +----------------------+
                                                    |    |    |
                                                    |    |    |
                                                +---+  +---+  +---+
                                                |Web|  |DB |  |App|
                                                +---+  +---+  +---+
                                               :80/443  :5432  :8080

Step 1: Sign Up and Log In

Step 2: Generate an SSH Key

ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub

Step 3: Create a New Droplet

Step 4: Initial Server Access

ssh root@YOUR_DROPLET_IP

Step 5: Create a Non-Root User

adduser deploy
passwd deploy
usermod -aG wheel deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

Step 6: Update Packages and Configure Firewall

sudo dnf update -y
sudo dnf install -y vim git curl wget
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

Step 7: Install and Configure Services

sudo dnf install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
git clone https://github.com/your-org/your-app.git /var/www/your-app

Step 8: Secure SSH Access

PermitRootLogin no
PasswordAuthentication no
sudo systemctl restart sshd

Post-Deployment

Monitoring

curl -sSL https://repos.insights.digitalocean.com/install.sh | sudo bash

Backups

pg_dump mydb > /backups/mydb_$(date +%F).sql

Security Hardening

sudo dnf install -y dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timer
sudo dnf install -y epel-release
sudo dnf install -y fail2ban
sudo systemctl enable --now fail2ban