How to Install OpenVPN on a VPS: A Step-by-Step Guide

We earn commissions when you shop through the links below.

calendar_month March 17, 2025 schedule 5 min read visibility 2610 views
person
Valebyte Team
How to Install OpenVPN on a VPS: A Step-by-Step Guide
summarize

TL;DR

  • • Connect to your VPS via SSH using `ssh user@vps_ip_address` to start the setup process.
  • • Install the required packages by running `sudo apt update` followed by `sudo apt install openvpn easy-rsa`.
  • • Initialize the Public Key Infrastructure (PKI) using `./easyrsa init-pki` within `/etc/openvpn/easy-rsa`.
  • • Generate and sign server and client certificates to establish secure, encrypted authentication.
dns No server for this guide yet? Vultr, DigitalOcean, Contabo or a ready-made VPN with no setup: NordVPN, Surfshark, Proton VPN sellDeal WebHosting UK: 10% off managed VPS until Nov 30 Get deal →

How to Install OpenVPN on a VPS?

A secure digital tunnel connecting a laptop to a server rack, symbolizing OpenVPN's role in creating secure, encrypted connections. OpenVPN is a popular technology used to create a secure connection over the internet. Installing OpenVPN on a VPS hosting allows you to ensure data transmission security and bypass access restrictions to resources on the Web. In this article, we will thoroughly analyze the process of installing OpenVPN on a virtual private server.

Step 1: Connecting to the VPS

The first step is to connect to your VPS via SSH. To do this, open a terminal and enter the command:

ssh user@vps_ip_address

Where "user" is your login, and "vps_ip_address" is the servers with IP addresses of your virtual server.

Step 2: Installing OpenVPN

To install OpenVPN on your VPS, execute the following commands:

  • sudo apt update
  • sudo apt install openvpn easy-rsa

These commands will update the packages on the server and install the necessary packages for OpenVPN to work.

dnsVPS for your own VPN

Matching plans from verified providers, prices updated daily.

sell WebHosting UK: 10% off managed VPS · until Nov 30 Get deal →

Compare:Vultr vs DigitalOceanVultr vs ContaboVPN services comparedAll VPS by price

Affiliate links: we may earn a commission, your price stays the same.

Step 3: Configuring OpenVPN

After installation, you need to copy the OpenVPN configuration files to the /etc/openvpn/ directory. This can be done with the following command:

sudo cp -r /usr/share/easy-rsa/ /etc/openvpn/

Next, you need to configure the security keys as follows:

cd /etc/openvpn/easy-rsa

./easyrsa init-pki

./easyrsa build-ca

These commands will create an authorization certificate for OpenVPN.

After that, you need to generate server and client certificates:

./easyrsa gen-req server nopass

./easyrsa sign-req server server

./easyrsa gen-req client nopass

./easyrsa sign-req client client

And, finally, create an encryption key:

./easyrsa gen-dh

After executing all the commands, the OpenVPN configuration will be ready for use on your VPS.

Step 4: Starting OpenVPN

To start OpenVPN, enter the following command:

sudo systemctl start openvpn

Now OpenVPN is running and ready to go. You can configure additional parameters in the configuration file /etc/openvpn/server.conf.

Step 5: Client Configuration

To connect a client to your OpenVPN server, you should configure the configuration files on the client side. Create a client.ovpn file and add the necessary settings to it.

After that, you can connect the client to the server using the command:

sudo openvpn --config client.ovpn

Conclusion

Now you have OpenVPN configured on your VPS, which provides a secure connection and protects your data on the Internet. Follow these steps and enjoy security and privacy online!

Don't want to set up a server?

A ready-made VPN: app, payment and running in 2 minutes.

Compare all VPNs: prices and countries →

Affiliate links: we may earn a commission, your price stays the same.