This repository contains scripts to easily set up an OpenVPN server using Docker containers. It supports multiple cloud providers and simplifies client certificate management.
- The script will create a file named
client-name.ovpn - Transfer this file securely to your client device
After running the setup script, your directory structure will look like this:
.
├── README.md
├── create-client.sh
├── docker-compose.yaml
├── openvpn-data/
│ └── conf/
│ ├── ccd/
│ ├── crl.pem
│ ├── openvpn.conf
│ ├── ovpn_env.sh
│ ├── pki/
│ └── server.conf
└── setup-openvpn.sh
Key files:
server.conf: Contains the server configuration including routing rulesopenvpn.conf: Main OpenVPN configuration filepki/: Contains all certificates and keysccd/: Client-specific configurations directory
Client Setup scripts to easily set up an OpenVPN server using Docker containers. It supports multiple cloud providers and makes it simple to manage client certificates.
- Docker and Docker Compose installed on your server
- A cloud VM/instance with ports opened:
- UDP 1194 (OpenVPN)
- Bash shell environment
- Amazon Web Services (AWS)
- Google Cloud Platform (GCP)
- Microsoft Azure
- Oracle Cloud Infrastructure (OCI)
- DigitalOcean
- And others (manual IP input available)
-
Clone this repository to your server:
git clone https://github.com/apoorvnema/OpenVPN-Community.git cd OpenVPN-Community -
Make the scripts executable:
chmod +x setup-openvpn.sh create-client.sh
-
Run the setup script:
./setup-openvpn.sh
- Choose your cloud provider when prompted
- Set a passphrase for the PKI when asked (remember this!)
-
Configure traffic routing:
echo 'push "redirect-gateway def1"' > openvpn-data/conf/server.conf
This configuration ensures that all client traffic is routed through the VPN.
-
Create a client certificate:
./create-client.sh client-name
Replace
client-namewith your desired client identifier (e.g., laptop, phone, etc.) -
Find your client configuration:
- The script will create a file named
client-name.ovpn - Transfer this file securely to your client device
- The script will create a file named
-
Install an OpenVPN client on your device:
- Windows/Mac/Linux: OpenVPN Connect
- Android: OpenVPN for Android
- iOS: OpenVPN Connect
-
Import the
.ovpnfile into your OpenVPN client -
Connect to your VPN server
-
To create additional client certificates:
./create-client.sh another-client
-
Each client gets their own
.ovpnfile -
Keep these files secure as they contain the certificates needed to connect to your VPN
- Store the PKI passphrase safely
- Keep
.ovpnfiles secure - Each client should have their own certificate
- Revocation process is not included in these basic scripts
This project uses the kylemanna/openvpn Docker image which is licensed under the GNU General Public License v2.0 (GPL-2.0). As such, this project is also distributed under the terms of GNU General Public License v2.0.
The setup and configuration scripts in this repository that wrap the Docker image are also licensed under GPL-2.0 to maintain license compatibility.
Feel free to open issues or submit pull requests for improvements.