Created
March 13, 2019 06:02
-
-
Save edwios/9cc3e3b490662f53b1c8b88c26b094e7 to your computer and use it in GitHub Desktop.
Script to setup OpenVPN server and keys
This file contains hidden or 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
# Create nologin openvpn user | |
adduser --system --shell /usr/sbin/nologin --no-create-home openvpn | |
apt install openvpn easy-rsa | |
apt install iptables-persistent | |
# Enable IPv4 forwarding | |
# Optional disable a bunch of IPv6 related stuff | |
vi /etc/sysctl.d/99-sysctl.conf | |
sysctl -p | |
# Create Cert directory | |
make-cadir /etc/openvpn/certs | |
# Create Client directory for ovpn clients | |
mkdir /etc/openvpn/clients | |
# Config openvpn | |
cd /etc/openvpn/certs | |
ln -s openssl-1.0.0.cnf openssl.cnf | |
export KEY_SIZE=4096 | |
# Edit vars | |
source ./vars | |
./clean-all | |
./build-ca | |
./build-key-server server | |
# following line takes a looooog time, enough to brew a cup of fresh coffee! | |
openssl dhparam 4096 > /etc/openvpn/dh4096.pem | |
openvpn --genkey --secret /etc/openvpn/certs/keys/ta.key | |
# Create/edit server config | |
vi /etc/openvpn/server.conf | |
systemctl start openvpn | |
systemctl start openvpn@server | |
systemctl enable openvpn | |
systemctl enable openvpn@server | |
# Verify status of server | |
systemctl status openvpn*.service | |
# Create OVPN clients | |
source ./vars | |
cd /etc/openvpn/clients | |
./build-key jpn-hy-ip7 | |
./build-ovpn.sh jpn-hy-ip7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment