forked from 9652040795/aws-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-client-vpn
111 lines (58 loc) · 2.89 KB
/
aws-client-vpn
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#Aurthor: Muhammad Asim
#Purpose: Setup OpenVPN in quick time.
sudo apt update -y > /dev/null
sudo apt install -y curl > /dev/null
sudo curl -fsSL https://get.docker.com -o get-docker.sh > /dev/null
sudo sh get-docker.sh > /dev/null
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose > /dev/null
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose > /dev/null
systemctl restart docker
systemctl enable docker
#We we are pulling the best Image of docker for OpenVPN on earth.
echo -e "\nWe we are pulling the best Image of OpenVPN for docker on earth by kylemanna/openvpn\n"
docker pull kylemanna/openvpn
#Step 1
echo -e "\nStep 1\n"
sleep 1
echo -e "\nPerforming Step 1, we are going to make a directory at /root/OpenVPN/openvpn_data\n"
mkdir -p /root/OpenVPN/openvpn_data
OVPN_DATA=/root/OpenVPN/openvpn_data
echo -e "\n$OVPN_DATA\n"
export OVPN_DATA
sleep 1
read -p "Please enter your Server Main IP Address or Domain Name IP: " IP
echo -e "\nYour Server IP is $IP\n"
#Step 2
echo -e "\nStep 2\n"
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://$IP
echo -e "\nAfter a Shortwhile You need to enter your Server Secure Password details please wait ...\n"
#Step 3
sleep 3
echo -e "\nWe are now at Step 3\n"
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
#Step 4
sleep 1
echo -e "\nStep 4, We are Starting OpenVPN server process please wait ...\n"
docker run --name OpenVPN -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --restart unless-stopped --cap-add=NET_ADMIN kylemanna/openvpn
sleep 3
echo "\nSee I am up and running Alhumdulliah\n"
docker ps -a
echo -e "\nMy name is OpenVPN, I am running inside the container name OpenVPN\n"
sleep 3
#Step 5
echo -e "\nWe are now at 5th Step, Generate a client certificate with a passphrase SAME AS YOU GIVE FOR SERVER...PASSPHRASE please wait...\n"
sleep 1
read -p "Please Provide Your Client Name " CLIENTNAME
echo -e "\nI am adding a client with name $CLIENTNAME\n"
#docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full $CLIENTNAME nopass
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full $CLIENTNAME
#Step 6
echo -e "\nWe are now at 6TH Step, don't worry this is last step, you lazy GUY,Now we retrieve the client configuration with embedded certificates\n"
echo -e "\n$CLIENTNAME ok\n"
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
#Note: If you remove the docker container by mistake, simply copy and paster 4TH Step, all will set as previously.
#END
#To revoke a client or user
# docker run --volumes-from ovpn-data --rm -it kylemanna/openvpn ovpn_revokeclient 1234 remove?