Created
August 27, 2020 14:45
-
-
Save WayneJLee/32032162ba9a1b166d59aed14486b36f to your computer and use it in GitHub Desktop.
Headless install and configuration of OpenVPN Access Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Originally from https://github.com/Azure/azure-quickstart-templates/blob/master/openvpn-access-server-ubuntu/install_openvpn_access_server.sh | |
userPassword=$1 | |
# adding official OpeenVPN Access Servere repository | |
sudo apt update && sudo apt -y install ca-certificates wget net-tools | |
wget -qO - https://as-repository.openvpn.net/as-repo-public.gpg | sudo apt-key add - | |
sudo sh -c 'echo "deb http://as-repository.openvpn.net/as/debian bionic main">>/etc/apt/sources.list.d/openvpn-as-repo.list' | |
# installing the OpenVPN Serve | |
sudo apt update && sudo apt -y install openvpn-as | |
# update the password for user openvpn | |
sudo echo "openvpn:$userPassword"|sudo chpasswd | |
# configure server network settings | |
PUBLICIP=$(curl -s ifconfig.me) | |
sudo apt-get install sqlite3 | |
# Updated to config_local.db because host.name is not stored in config.db | |
sudo sqlite3 "/usr/local/openvpn_as/etc/db/config_local.db" "update config set value='$PUBLICIP' where name='host.name';" | |
sudo sqlite3 "/usr/local/openvpn_as/etc/db/config_local.db" "update config set value='10.10.10.0' where name='vpn.daemon.0.client.network';" | |
sudo sqlite3 "/usr/local/openvpn_as/etc/db/config_local.db" "update config set value='24' where name='vpn.daemon.0.client.netmask_bits';" | |
sudo sqlite3 "/usr/local/openvpn_as/etc/db/config_local.db" "update config set value='route' where name='vpn.server.routing.private_access';" | |
sudo sqlite3 "/usr/local/openvpn_as/etc/db/config_local.db" "insert into config values(1,'vpn.server.routing.allow_private_nets_to_clients','true');" | |
# restart OpenVPN AS service | |
sudo systemctl restart openvpnas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment