OpenVPN Installation on an Ubuntu-based Linux Server

This guide provides a simple method to install OpenVPN on Ubuntu using an automated script. The script handles most of the configuration for you.


Step 1: Update Your System

Ensure your system packages are up-to-date.

sudo apt update && sudo apt upgrade -y

Step 2: Download the OpenVPN Installation Script

We'll use a trusted script that automates the OpenVPN installation process.

wget https://git.io/vpn -O openvpn-install.sh

This script is maintained by Nyr on GitHub.

Step 3: Make the Script Executable

chmod +x openvpn-install.sh

Step 4: Run the Installation Script

sudo ./openvpn-install.sh

Step 5: Follow the Prompts

The script will ask you a few simple questions:

  1. IP Address Detection:
    • It will automatically detect your server's public IP address. Press Enter to accept or enter a different IP if needed.
  2. Protocol Selection:
    • Choose the protocol (UDP or TCP). UDP is recommended. Type 1 for UDP and press Enter.
  3. Port Number:
    • Enter the port number for OpenVPN. The default is 1194. Press Enter to accept the default.
  4. DNS Provider:
    • Select a DNS provider for the VPN clients. You can choose from a list (e.g., Google, Cloudflare). Enter the corresponding number and press Enter.
  5. Client Name:
    • Enter a name for the first VPN client (e.g., client1). This will generate a configuration file for this client.
  6. Confirm Installation:
    • Press any key to start the installation.

Step 6: Installation Complete

Once the script finishes:

  • The OpenVPN server is set up and running.
  • A client configuration file (e.g., client1.ovpn) is generated in your home directory.

Step 7: Transfer the Client Configuration File

Transfer the .ovpn file to the device you want to use as a VPN client. You can use secure methods like scp, sftp, or a USB drive.

Example using scp:

scp ~/client1.ovpn your_username@client_ip:/path/to/destination

Step 8: Connect to the VPN from the Client

  1. Install OpenVPN Client:
    • For Windows: Download and install the OpenVPN client.
    • For macOS: Use Tunnelblick or the official OpenVPN Connect client.
    • For Linux: Install OpenVPN using your package manager.
    sudo apt install openvpn -y
    
  2. Import the Configuration File:
    • Open the OpenVPN client application.
    • Import the client1.ovpn file.
  3. Connect to the VPN:
    • Use the client application to connect using the imported profile.

Managing OpenVPN After Installation

You can manage OpenVPN by re-running the installation script:

sudo ./openvpn-install.sh

Options include:

  • Add a new client: Generate additional client configuration files.
  • Revoke existing clients: Remove client access.
  • Uninstall OpenVPN: Completely remove OpenVPN from your server.

Security Considerations

  • Review the Script: It's good practice to review any script before running it. Open the script with a text editor to inspect it.
nano openvpn-install.sh
  • Keep Your System Updated: Regularly update your server to patch security vulnerabilities.
sudo apt update && sudo apt upgrade -y
  • Firewall Configuration: Ensure that the OpenVPN port (1194 by default) is open in your firewall settings.
sudo ufw allow 1194/udp

Additional Resources


This method provides a quick and easy way to set up OpenVPN on your Ubuntu server with minimal configuration. If you need further assistance, feel free to consult the additional resources or reach out to the community.

  • OpenVPN, Ubuntu
  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

hTOP Command Installation On Linux Server

To install and use the htop command on YUM-based Linux distributions like CentOS and AlmaLinux,...

DirectAdmin Control Panel Installation Guideline Linux Server

DirectAdmin is a powerful and user-friendly web hosting control panel. This guide will walk you...

CyberPanel Installation on Linux Server

CyberPanel is a next-generation web hosting control panel powered by OpenLiteSpeed. It offers a...

cPanel Installation on Linux

cPanel & WHM is a leading web hosting control panel that provides a graphical interface and...

Apache Installation Process in Linux Based Server

This guide provides an easy method to install the Apache HTTP Server on various Linux...