Devops OpenVPN Installation process
This is likely going to be already deprecated as we're on talks to move to Hetzner Teleport instead.
Not sure if Ansible scripts are going to be necessary, read above 👆 TO DO: Ansible scripts. Below is summary of the installation process to help with creating ansible scripts.
CA
- Update package repositories and install
openvpnandeasy-rsa
sudo apt update
sudo apt install openvpn easy-rsa
- Create
causer:
sudo adduser ca
- Switch to ca-user:
sudo su ca
- Change directories to home:
cd
- Create
easy-rsadirectory:
mkdir ~/easy-rsa
- Symlink easy-rsa scripts to our home's easy-rsa directory so when updating easy-rsa, updates are "applied" to our easy-rsa directory as well.
ln -s /usr/share/easy-rsa/* ~/easy-rsa/
- Ensure that only the
causer is allowed to access the easy-rsa directory in their home:
chmod 700 ~/easy-rsa
- Add configurations to
varsfile:
set_var EASYRSA_REQ_COUNTRY "FI"
set_var EASYRSA_REQ_PROVINCE "Keski-Pohjanmaa"
set_var EASYRSA_REQ_CITY "Kokkola"
set_var EASYRSA_REQ_ORG "Ahola Digital"
set_var EASYRSA_REQ_EMAIL "miro.salo@aholadigital.com"
set_var EASYRSA_REQ_OU "aholadigital"
set_var EASYRSA_ALGO "ec"
set_var EASYRSA_DIGEST "sha512"
- Run the
build-cascript:
./easyrsa build-ca
- Create SSH keys for both
ovpnandcauser accounts:
ssh-keygen -t ed25519
- Create
authorized_keysfile for both user accounts under/home/<USERNAME>/.ssh/ - As the relevant user (ovpn and ca), give it proper permissions so that it doesn't error out:
chmod 644 authorized_keys
- Add the contents of ovpn's
.pubpublic key to ca-user'sauthorized_keysfile located in/home/ca/.ssh/authorized_keys - Add the contents of ca's
.pubpublic key to ovpn-user'sauthorized_keysfile located in/home/ovpn/.ssh/authorized_keys - As the ovpn-user, copy the
ca.crtfile from the ca-user's home:
rsync -v ca@192.168.1.3:~/easy-rsa/pki/ca.crt ~
- Log out from the ovpn-user and move the certificate file:
exit
sudo mv /home/ovpn/ca.crt /usr/local/share/ca-certificates/
- As yourself, run the certificate update command:
sudo update-ca-certificates
VPN
- Update package repositories and install
openvpnandeasy-rsa
sudo apt update
sudo apt install openvpn easy-rsa
- Create
ovpnuser:
sudo adduser ovpn
- Switch to ovpn-user:
sudo su ovpn
- Change directories to home:
cd
- Create
easy-rsadirectory:
mkdir ~/easy-rsa
- Symlink easy-rsa scripts to our home's easy-rsa directory so when updating easy-rsa, updates are "applied" to our easy-rsa directory as well.
ln -s /usr/share/easy-rsa/* ~/easy-rsa/
- Ensure that only the
ovpnuser is allowed to access the easy-rsa directory in their home:
chmod 700 ~/easy-rsa
- Add configurations to
varsfile:
cd ~/easy-rsa
nano vars
set_var EASYRSA_ALGO "ec"
set_var EASYRSA_DIGEST "sha512"
- ./easyrsa init-pki
TODO continue this?