-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-openvpn-client-tar.sh
executable file
·76 lines (58 loc) · 1.25 KB
/
make-openvpn-client-tar.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
echo "Build a client config tarball for openvpn."
if [[ -z "$1" ]]
then echo "USAGE: $0 newopenvpnclientname"
exit 1
fi
OUTDIR="$(pwd)"
NAME=$1
(
cd /etc/openvpn/rsa
source vars
./pkitool $NAME
)
[[ -f /etc/openvpn/rsa/keys/$NAME.key ]] || exit 3
[[ -f /etc/openvpn/rsa/keys/$NAME.key ]] || exit 4
TEMPDIR=`mktemp -d`
mkdir -p $TEMPDIR/openvpn || exit 2
cd $TEMPDIR/openvpn || exit 5
chmod 0700 .
cp /etc/openvpn/rsa/keys/$NAME.key ./
cp /etc/openvpn/rsa/keys/$NAME.crt ./
cp /etc/openvpn/ca.pizza.crt ./
cp /etc/openvpn/ta.pizza.key ./
cat >pizza.conf <<EOF
client
proto udp
dev tun2
ca ca.pizza.crt
cert $NAME.crt
key $NAME.key
remote pizza.cs.ualberta.ca 1194
nobind
ns-cert-type server
tls-auth ta.pizza.key 1
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 4
ping 1
ping-restart 20
EOF
cat >instructions.txt <<EOF
Place these files in /etc/openvpn!
Then start openvpn.
systemctl start [email protected]
systemctl enable [email protected]
Take note of your IP address for tun2 which will be 192.168.2.x
ip addr dev tun2
To see logs:
journalctl -u [email protected]
EOF
cd "$OUTDIR"
tar -cvaf $NAME.txz -C $TEMPDIR openvpn || exit 6
echo "Your client config is in $NAME.txz"