Python script to provision virtual machine, create port forwards and install OpenVPN Cloud-init.
openvpn_installer.py
export MY_JWT = ""
Copy public your public ssh key into openvpn/openvpn_installer folder to enable you to access the server remotely after installation
cp <ssh_pub_key> openvpn/openvpn_installer/
The scripts can run in any Python 3 environment. In this case, a docker container based on the GiG docker tools image will be used.
git clone [email protected]:gig-tech/GIG-Docker-Tools.git
ARG_JWT=
ARG_VCO_API_URL=
export ARG_JWT
export ARG_VCO_API_URL
cd gig_tools/cli_terraform
docker build --build-arg ARG_JWT --build-arg ARG_VCO_API_URL -t <vco_name> .
cd <working_dir>
git clone [email protected]:gig-tech/OpenVPN.git
cd openvpn
- Add your JWT to env_list file variable -> MY_JWT= using your favorite editor.
docker run --env-file env_list -w /root/home/ --mount type=bind,source=$PWD,target=/root/home -i -t <vco_name> /bin/bash
pip3 install pipenv
pipenv shell
pip3 install requests paramiko scp click
python3 openvpn_installer/openvpn_installer.py deploy-server --help
Installation of OpenVPN takes about five minutes. This command will not work until the installation is complete. You will get "..File not found!" message if attempted before 5 mins have elapsed.
python3 openvpn_installer/openvpn_installer.py --help
- Import client file into VPN client.
- Install OpenVPN client using
sudo apt update
sudo apt install -y openvpn resolvconf openvpn-systemd-resolved easy-rsa
openvpn --config client1.ovpn # Place your client1.ovpn file in your current directory
- If systemd-resolved - comment out the following block of code in the client config file
script-security 2
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre
dhcp-option DOMAIN-ROUTE .
- Or update-resolv-conf - comment out the following block of code in the client config file
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
ping xyx.xyx.xyx.xyz