Security
Difficulty: Advanced
4 min read

OpenVPN Server: Set up your own VPN server

Complete tutorial to install and configure an OpenVPN server, in order to create a secure virtual private network.

Back to tutorials
What is a VPN?
A VPN (Virtual Private Network) creates a secure, encrypted "tunnel" for your internet traffic. This protects your data from prying eyes on unsecured networks (such as public Wi-Fi) and lets you access resources on a remote network as if you were physically there. OpenVPN is one of the most robust and reliable solutions for creating a VPN server.

Why use OpenVPN?

  • Open-Source and Audited: The code is public and has been audited multiple times.
  • Highly Configurable: Offers very fine-grained control over encryption protocols, ports and network options.
  • Cross-platform: Clients exist for virtually every operating system (Windows, macOS, Linux, Android, iOS).
  • Solid Security: Uses the OpenSSL library and the TLS protocol for cutting-edge security.

Prerequisites

  • A dedicated Linux server (Ubuntu/Debian recommended), which will be your VPN server.
  • Root access or sudo privileges.
  • A static IP address on the server.

Premium Content

This advanced tutorial is reserved for premium members.

9,90€ / month
  • All advanced tutorials
  • New content every week
  • Progress tracking
  • Cancel anytime

Written by

Morgann Riu

Cybersecurity and Linux administration expert. I share my knowledge through free tutorials and training to help system administrators and developers secure their infrastructures.

Frequently asked questions

Should I configure OpenVPN by hand or use a script?
By hand you have to set up the certificate authority, generate and sign the server and client certificates, and write the firewall and routing rules: an excellent learning exercise, but long and easy to break on a single detail. Nyr's script runs that sequence consistently and hands you a working server in a few minutes. For a first installation, take the script; keep the manual route for understanding what it did.
How do I add or revoke a client once the server is in production?
Do not start a fresh installation: just re-run sudo ./openvpn-install.sh. The script detects the existing setup and switches to a management menu that lets you add a new user (generating their .ovpn), revoke an existing user, or uninstall OpenVPN. Revocation is the right answer to a lost laptop or someone leaving.
Why does the server need a static IP address?
Because the server address is hard-coded into every .ovpn file handed out to clients. If the public IP changes, every already-deployed profile points at nothing and no client can connect — you then have to regenerate and redistribute the configurations one by one. It is also what lets you cleanly open port 1194/UDP on the firewall.
Does a self-hosted VPN make me anonymous online?
No, and this is a common confusion. It does encrypt your connection and hide your IP behind the server's from the sites you visit, which solves the untrusted Wi-Fi problem. But your hosting provider (OVH, Scaleway, DigitalOcean...) can see that you connect to your server, and all outbound traffic carries an IP that is registered in your name. For actual anonymity, a commercial no-logs service is a better fit.
How do I transfer the .ovpn file without compromising the VPN?
That file contains the client keys: anyone who gets hold of it can connect to your VPN. It must therefore never travel over email, chat or an HTTP link. Use scp from your local machine, for example scp root@SERVER_IP:/root/my-laptop.ovpn ., which goes through the already encrypted and authenticated SSH channel. If a profile ever leaks, revoke it from the installation script menu.

Share this tutorial

Did you enjoy this article?

Comments

Checklist Sécurité Linux

30 points essentiels pour sécuriser un serveur Linux. Recevez aussi les nouveaux tutoriels par email.

Pas de spam. Désabonnement en 1 clic.