-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwin-client.sh
More file actions
71 lines (59 loc) · 2 KB
/
win-client.sh
File metadata and controls
71 lines (59 loc) · 2 KB
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
#!/bin/bash
display_usage() {
echo "This script creates a configuration for Windows Systems"
echo ""
echo "Usage: ./win-client.sh <client-name>"
}
create_client_config() {
ClientDir=/etc/openvpn/$1
ClientConf=/etc/openvpn/$1/$1.ovpn
PublicIP=$(curl -s icanhazip.com)
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] Prepping Client Environment\e[0m\e[39m"
sudo mkdir $ClientDir
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] Getting Client Cetificate for $1\e[0m\e[39m"
gzip -d /usr/share/doc/openvpn/examples/sample-keys/client.crt.gz
cp /usr/share/doc/openvpn/examples/sample-keys/{client.crt,client.key} $ClientDir
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] Creating Config\e[0m\e[39m"
echo client >> $ClientConf
echo dev tun >> $ClientConf
echo dev-node OpenVPN >> $ClientConf
echo proto tcp >> $ClientConf
echo remote $PublicIP 1194 >> $ClientConf
echo resolv-retry infinite >> $ClientConf
echo nobind >> $ClientConf
echo persist-key >> $ClientConf
echo persist-tun >> $ClientConf
echo ca ca.crt >> $ClientConf
echo cert client.crt >> $ClientConf
echo key client.key >> $ClientConf
echo remote-cert-tls server >> $ClientConf
echo tls-auth ta.key 1 >> $ClientConf
echo cipher AES-256-CBC >> $ClientConf
echo verb 0 >> $ClientConf
echo tls-client >> $ClientConf
echo key-direction 1 >> $ClientConf
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] Copying CA and TA\e[0m\e[39m"
cp /etc/openvpn/ca.crt $ClientDir/
cp /etc/openvpn/ta.key $ClientDir/
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] Compressing Client Config\e[0m\e[39m"
zip -j $ClientDir/$1.zip $ClientDir/*.*
cp $ClientDir/$1.zip /var/www/vpn-client
chmod a+rx /var/www/vpn-client -R
echo -e "\e[1m\e[32m[\e[1m\e[31m*\e[1m\e[32m] You can now download the ZIP at https://$PublicIP/$1.zip\e[0m\e[39m"
}
if [[ $USER -ne "root" ]]
then
echo -e "\e[1m\e[31mRun as root!\e[39m\e[0m"
exit 1
fi
if [[ ($# == "--help") || $# == "-h" ]]
then
display_usage
exit 0
fi
if [ $# -le 0 ]
then
display_usage
exit 1
fi
create_client_config "$1"