-
Notifications
You must be signed in to change notification settings - Fork 6
/
vpn-setup.sh
executable file
·32 lines (29 loc) · 1.1 KB
/
vpn-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
TARGET="$(pwd)"
cd "$(mktemp -d)" || exit
git clone -b v3.1.0 https://github.com/OpenVPN/easy-rsa.git
cat > easy-rsa/easyrsa3/vars << EOF
set_var EASYRSA_DN "cn_only"
set_var EASYRSA_KEY_SIZE 2048
set_var EASYRSA_BATCH "yes"
EOF
(
cd easy-rsa/easyrsa3 || exit
./easyrsa init-pki
mv vars pki/
./easyrsa --batch --req-cn="[email protected]" build-ca nopass
./easyrsa --batch --req-cn="[email protected]" build-server-full server nopass
./easyrsa --batch --req-cn="[email protected]" build-client-full client nopass
openvpn --genkey --secret pki/private/ta.key
cd pki || exit
mkdir "$TARGET/openvpn-server/secrets/" "$TARGET/openvpn-client/secrets/"
# Distribute CA and TA
cp ca.crt private/ca.key private/ta.key "$TARGET/openvpn-server/secrets/"
cp ca.crt private/ca.key private/ta.key "$TARGET/openvpn-client/secrets/"
# Distribute Server
cp private/server.key issued/server.crt "$TARGET/openvpn-server/secrets/"
# Distribute Client
cp private/client.key issued/client.crt "$TARGET/openvpn-client/secrets/"
)
pwd
ls -lh easy-rsa/easyrsa3/pki/issued