How to Set Up an OpenVPN Server on a VPS

OpenVPN is a mature, widely-supported VPN protocol — a solid choice when you need broad client compatibility or specific features not available in newer alternatives like WireGuard.

OpenVPN vs WireGuard

FactorOpenVPNWireGuard
Setup complexityMore involved (PKI, certificates)Simpler (key pairs only)
PerformanceGoodGenerally faster
Client compatibilityExtremely broad, mature ecosystemGrowing, native in most modern OSes now

Prerequisites

  • Ubuntu 22.04/24.04 VPS
  • Root or sudo access

Step 1 — Use the Official Installation Script (Simplest Approach)

curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
sudo ./openvpn-install.sh

This well-maintained community script automates the otherwise complex manual PKI setup process, walking through an interactive configuration wizard.

Step 2 — Follow the Interactive Prompts

Configure: the public IP/hostname clients will connect to, the protocol (UDP recommended for performance), the port, and DNS resolver preference for clients.

Step 3 — Create Your First Client

The script prompts for a client name and generates a .ovpn configuration file containing all necessary certificates and settings.

Step 4 — Transfer the Client Config Securely

scp deploy@YOUR_SERVER_IP:~/client.ovpn ./

Step 5 — Connect from a Client

Import the .ovpn file into the OpenVPN Connect app (available for all major platforms) and connect.

Adding Additional Clients Later

sudo ./openvpn-install.sh

Re-run the script and select the "Add a new user" option from its menu.

Revoking Client Access

sudo ./openvpn-install.sh

Select the "Revoke existing user" option — important for immediately cutting off access for a lost device or departed team member.

Verifying the Server Is Running

sudo systemctl status openvpn@server

Checking Connected Clients

sudo cat /var/log/openvpn/status.log

Manual Setup Considerations (If Not Using the Script)

A manual OpenVPN setup involves generating a Certificate Authority, server certificate, and per-client certificates using Easy-RSA — considerably more involved than the WireGuard equivalent, which is why most administrators use an automation script like the one above rather than configuring OpenVPN's PKI by hand.

Common Errors

Client can't connect — verify the configured port (default UDP 1194, or whatever was chosen during setup) is allowed through the firewall.

Slow VPN throughput — try switching from TCP to UDP if not already using it; TCP-over-TCP tunneling situations can cause significant performance degradation.

Best Practices

  • Use a unique client certificate per device, never share one certificate across multiple devices
  • Revoke certificates immediately for lost devices or departed team members
  • Prefer UDP over TCP for better performance unless you have a specific reason requiring TCP

Continue Reading

Browse more articles in Advanced Networking & VPN.

  • openvpn, vpn server setup, openvpn install script, self hosted vpn
  • 0 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

How to Set Up a VPN Server with WireGuard

WireGuard is a modern, fast, and simple VPN protocol — significantly easier to configure...

How to Configure a VPS as a Forward Proxy with Squid

A forward proxy routes outbound requests through your VPS, useful for accessing geo-restricted...

How to Set Up IPv6 on Your VPS

IPv6 adoption continues to grow, and many VPS providers now offer IPv6 addresses alongside IPv4....

How to Bond Multiple Network Interfaces for Redundancy

Network interface bonding combines multiple physical/virtual network interfaces into a single...

How to Set Up a Site-to-Site VPN Between Two VPS Servers

A site-to-site VPN creates a persistent, secure tunnel between two servers (or entire networks),...