Last active
July 6, 2020 15:15
-
-
Save kylemanna/3adcd465e709b8ff3300202f12fdfff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Blog post @ https://blog.kylemanna.com/sharing/gogo-inflight-wireless-with-openvpn/ | |
# | |
# Bail on errors | |
set -e | |
SERVER_IP=$(host myip.opendns.com. resolver1.opendns.com | awk '/has address/ { print $4 }') | |
OVPN_DATA="ovpn-data" | |
echo "[*] Generating server config for $SERVER_IP" | |
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://$SERVER_IP:3128 | |
echo "[+] Generated server config for $SERVER_IP" | |
echo "[*] Initialzing PKI (insecurely) for the truely lazy" | |
docker run -v $OVPN_DATA:/etc/openvpn --rm -e "EASYRSA_BATCH=1" kylemanna/openvpn ovpn_initpki nopass | |
echo "[+] Initialized PKI magic" | |
echo "[*] OpenVPN server starting up" | |
docker run -v $OVPN_DATA:/etc/openvpn -d -p 3128:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn | |
echo "[+] OpenVPN server up and running" | |
CLIENT=client1 | |
echo "[*] Generating client certificate for $CLIENT" | |
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn easyrsa build-client-full $CLIENT nopass | |
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient $CLIENT > $CLIENT.ovpn | |
echo "[*] Client certificate ready at $CLIENT.ovpn" | |
cat <<EOF | |
_______________________________________ | |
< Server up and running, happy surfing > | |
--------------------------------------- | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
EOF | |
echo "[?] Copy $CLIENT.ovpn to your client" | |
echo "[x] Exiting" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment