Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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