Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.98 KB

README.md

File metadata and controls

43 lines (27 loc) · 1.98 KB

Setup an OpenVPN server at DigitalOcean

If you're in desperate need of an OpenVPN you can just use this Terraform config to start one at DigitalOcean.

The installation is based on this guide and uses the user data provided by the guide.

Setup

We use dotenv to manage the secrets. To install it you need both Ruby and Bundler installed. Run:

$ bundle

After this copy .env.sample to .env and fill in your ssh_key ID from DigitalOcean and your DigitalOcean token. A token can be created at the DigitalOcean website. To find your ssh key ID you need to ask the DigitalOcean API:

$ curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $DIGITAL_OCEAN_TOKEN" "https://api.digitalocean.com/v2/account/keys"

Creating the Droplet

With everything setup you can now create the droplet. OpenVPN will be installed using the above mentioned user data so no special provisioning step is required. You need to first plan your terraform run:

$ dotenv terraform plan -out openvpn.out

If everything looks good apply the plan:

$ dotenv terraform apply openvpn.out

Using the OpenVPN

After the terraform run has been completed you will see the droplet's IP address. Use this address to copy the unified OpenVPN config from the server:

$ scp root@$DROPLET_IP:/etc/openvpn/easy-rsa/keys/client.ovpn /path/to/local/DigitalOcean.ovpn

Now you could import that config into your OpenVPN client of choice. For more guidance on that topic follow the DigitalOcean guide.