DigitalOcean VPN Setup

Step-by-step guide to creating and configuring a VPN server on DigitalOcean

📋 Prerequisites

  • DigitalOcean account with billing information
  • SSH key pair (we'll help you create one)
  • Basic command line knowledge

1 Create SSH Key Pair

Generate SSH Key (Local Machine)

On your local machine, generate an SSH key pair:

Local Terminal
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cat ~/.ssh/id_rsa.pub

Copy the output of the second command - you'll need it for DigitalOcean.

2 Create DigitalOcean Droplet

Droplet Configuration

Recommended Settings

  • Image: Ubuntu 22.04 LTS
  • Plan: Basic ($5/month minimum)
  • CPU: 1 vCPU, 1GB RAM
  • Storage: 25GB SSD
  • Region: Choose closest to you

Security Settings

  • Authentication: SSH keys (paste your public key)
  • Firewall: Create new firewall
  • Monitoring: Enable (recommended)
  • Backups: Optional (+20% cost)

Firewall Rules

Configure these firewall rules for your droplet:

TypeProtocolPort RangeSources
SSHTCP22All IPv4, All IPv6
OpenVPNUDP1194All IPv4, All IPv6
WireGuardUDP51820All IPv4, All IPv6

3 Connect to Your Droplet

SSH Connection

Once your droplet is created, connect via SSH:

Local Terminal
ssh root@YOUR_DROPLET_IP

Replace YOUR_DROPLET_IP with the actual IP address shown in your DigitalOcean dashboard.

4 Install VPN Software

Option A: WireGuard (Recommended)

Fast, modern, and secure:

Droplet Terminal
curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.sh
Detailed WireGuard Guide →

Option B: OpenVPN

Mature and widely compatible:

Droplet Terminal
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
./openvpn-install.sh
Detailed OpenVPN Guide →

5 DigitalOcean Optimizations

Enable Monitoring

Install the DigitalOcean monitoring agent:

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

Configure Automatic Updates

Droplet Terminal
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure -plow unattended-upgrades

💰 Cost Optimization Tips

Reduce Costs

  • • Use the smallest droplet size that meets your needs
  • • Consider shared CPU vs dedicated CPU based on usage
  • • Enable monitoring to track resource usage
  • • Use snapshots instead of backups for occasional backups

Pricing Examples

  • • Basic: $5/month (1GB RAM, 1 vCPU, 25GB SSD)
  • • Regular: $10/month (2GB RAM, 1 vCPU, 50GB SSD)
  • • Premium: $20/month (4GB RAM, 2 vCPU, 80GB SSD)
  • • Bandwidth: 1TB included, $0.01/GB overage

🎉 Next Steps

Your DigitalOcean VPN server is ready! Here's what to do next:

Client Setup

  • • Download VPN client for your devices
  • • Import configuration files
  • • Test connection and check IP address

Security

  • • Regularly update your server
  • • Monitor connection logs
  • • Consider fail2ban for additional security