Custom VPN Walkthrough

Prerequisites

Generate a droplet

sudo apt install openssh-server openssh-client

Generate another droplet for CA

Step 1

Step 2

Step 3 - PKI directory

Step 4

~/easy-rsa/vars

set_var EASYRSA_REQ_COUNTRY “US”

set_var EASYRSA_REQ_PROVINCE “Hawaii”

set_var EASYRSA_REQ_CITY “Honolulu”

set_var EASYRSA_REQ_ORG “DigitalOcean”

set_var EASYRSA_REQ_EMAIL “tyoung24@hawaii.edu”

set_var EASYRSA_REQ_OU “Community”

set_var EASYRSA_ALGO “ec”

set_var EASYRSA_DIGEST “sha512”

Step 5 - Distributing your Certificate Authority’s Public Certificate

Public Keys

sudo apt install openssh-server openssh-client

OpenVPN

Installing OpenVPN and Easy RSA

Creating a PKI

Create a certificate request and private key

Signing the certificate

On CA server

On VPN server

Configuring OpenVPN cryptographic material

Generate client certificate and key pair

On CA server

On VPN Server

Configure OpenVPN

change ‘;tls-auth ta.key 0 # This file is secret’ to tls-crypt ta.key

change ‘;cipher AES-256-CBC’ to cipher AES-256-GCM

change ‘;dh dh2048.pem’ to dh none

uncomment

if it says group nobody, change it to nobody

Adjust port 1194 to 443 and change protocol to proto tcp

change explicity-exit-notify 0

This is necessary for TCP or it will cause errors.

change port 1194 to 443

uncomment proto tcp

Adjusting networking configuration

sudo sysctl -p should output “net.ipv4.ip_forward = 1”

Firewall conf

-ip route list default output: default via 159.65.160.1 dev eth0 proto static

-sudo nano /etc/ufw/before.rules

paste :

# START OPENVPN RULES

# NAT table rules

*nat

:POSTROUTING ACCEPT [0:0]

# Allow traffic from OpenVPN client to eth0 (change to the interface you discovered!)

-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE

COMMIT

# END OPENVPN RULES

save and close

allowing 443 and 53 means our traffic will never be blocked

Starting OpenVPN

Check if it started

Creating Client Config Infrastructure

uncomment:

# Downgrade privileges after initialization (non-Windows only)

user nobody

group nogroup

comment out ca, cert, key, and tls-auth ta.key 1

mirror cipher and auth

cipher AES-256-GCM

auth SHA256

add key-direction somewhere

key-direction 1

comment out

; script-security 2

; up /etc/openvpn/update-resolv-conf

; down /etc/openvpn/update-resolv-conf

; script-security 2

; up /etc/openvpn/update-systemd-resolved

; down /etc/openvpn/update-systemd-resolved

; down-pre

; dhcp-option DOMAIN-ROUTE .

save and close

nano ~/client-configs/make_config.sh

#!/bin/bash

# First argument: Client identifier

KEY_DIR=~/client-configs/keys

OUTPUT_DIR=~/client-configs/files

BASE_CONFIG=~/client-configs/base.conf

cat ${BASE_CONFIG} \

<(echo -e ‘') \

${KEY_DIR}/ca.crt \

<(echo -e ‘</ca>\n') \

${KEY_DIR}/${1}.crt \

<(echo -e ‘</cert>\n') \

${KEY_DIR}/${1}.key \

<(echo -e ‘</key>\n') \

${KEY_DIR}/ta.key \

<(echo -e ‘</tls-crypt>’) \

${OUTPUT_DIR}/${1}.ovpn

Mark this as an executable

Generating Client Configurations

On your local machine

uncomment:

connect with:

AlgoVPN

get a copy of algo

on client machine (linux)

Locate the config file

Install config file

Wireguard on pc

Download wireguard and setup

Start wireguard on linux

Cronjobs