2025-03-22 22:16:48 +00:00
2025-03-22 19:58:05 +00:00
2025-03-19 19:27:42 -05:00
2025-03-22 22:16:48 +00:00

OpenVPN Server Setup Script

This script automates the process of setting up an OpenVPN server on a VPS running Ubuntu/Debian. It handles the installation, certificate generation, and configuration of OpenVPN.

Prerequisites

  • A VPS running Ubuntu/Debian
  • Root access to the server
  • OpenSSH access to the server

Installation

  1. Copy the setup_openvpn.sh script to your server
  2. Make the script executable:
    chmod +x setup_openvpn.sh
    
  3. Run the script as root:
    sudo ./setup_openvpn.sh
    

What the Script Does

  1. Updates the system
  2. Installs OpenVPN and required packages
  3. Sets up the PKI (Public Key Infrastructure)
  4. Generates server certificates and keys
  5. Configures the OpenVPN server
  6. Sets up firewall rules
  7. Creates a client certificate generation script

Generating Client Certificates

After the server is set up, you can generate client certificates using the provided script:

sudo /etc/openvpn/server/generate-client.sh <client-name>

This will create a client configuration file in /etc/openvpn/client/<client-name>.ovpn

Connecting to the VPN

  1. Copy the generated .ovpn file from /etc/openvpn/client/ to your local machine
  2. Install OpenVPN client on your local machine
  3. Import the .ovpn file into your OpenVPN client
  4. Connect to the VPN

Security Notes

  • The script uses UDP port 1194 (default OpenVPN port)
  • AES-256-CBC encryption is used
  • The server uses Google DNS (8.8.8.8 and 8.8.4.4)
  • The VPN subnet is set to 10.8.0.0/24
  • The script enables IP forwarding and configures the firewall

Troubleshooting

If you encounter any issues:

  1. Check the OpenVPN server logs:
    sudo journalctl -u openvpn@server
    
  2. Verify the firewall rules:
    sudo ufw status
    
  3. Check if the OpenVPN service is running:
    sudo systemctl status openvpn@server
    

Important Files

  • Server configuration: /etc/openvpn/server/server.conf
  • Client configurations: /etc/openvpn/client/
  • Server certificates: /etc/openvpn/server/
  • Client certificate generation script: /etc/openvpn/server/generate-client.sh
Description
No description provided
Readme 41 KiB
Languages
Shell 100%