forked from nicolargo/openvpnscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathovcreateclient.sh
More file actions
executable file
·63 lines (54 loc) · 1.27 KB
/
ovcreateclient.sh
File metadata and controls
executable file
·63 lines (54 loc) · 1.27 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
#!/bin/bash
#
# Script de creation d'un nouveau client sur un serveur OpenVPN
# http://blog.nicolargo.com/2010/10/installation-dun-serveur-openvpn-sous-debianubuntu.html
#
# Nicolargo - 10/2010
# Frederic Le Barzic - 08/2012
# GPL
#
# Syntaxe: # ./ovcreateclient.sh <nomduclient>
VERSION="0.1b"
# Test que le script est lance en root
if [ $EUID -ne 0 ]; then
echo "Le script doit etre lance en root: # $0 <nomduclient>" 1>&2
exit 1
fi
# Test parametre
if [ $# -ne 1 ]; then
echo "Il faut saisir le nom du client: # $0 <nomduclient>" 1>&2
exit 1
fi
echo "---"
echo "Creation du client OpenVPN: $1"
cd /etc/openvpn/easy-rsa
source vars
./build-key $1
sudo mkdir /etc/openvpn/clientconf/$1
sudo cp /etc/openvpn/keys/ca.crt /etc/openvpn/keys/ta.key keys/$1.crt keys/$1.key /etc/openvpn/clientconf/$1/
cd /etc/openvpn/clientconf/$1
cat >> $1.conf << EOF
# Client
client
dev tun
proto tcp-client
remote 00.00.00.00 443
resolv-retry infinite
cipher AES-256-CBC
# Cles
ca ca.crt
cert $1.crt
key $1.key
tls-auth ta.key 1
# Securite
nobind
persist-key
persist-tun
comp-lzo
verb 3
EOF
sudo cp $1.conf $1.ovpn
sudo zip $1.zip *.*
echo "Creation du client OpenVPN $1 termine"
echo "/etc/openvpn/clientconf/$1/$1.zip"
echo "---"