I was recently setting up some AWS EC2 instances for lab redundancy and decided to create a VPN tunnel straight to my homelab for a bit of extra security. Thankfully, clients are much more simple to setup via command line than servers…
You’ll first need to create OpenVPN configuration files on the OpenVPN server. You can transfer these with SCP
scp -r /path/to/conf/* [email protected]:/path/to/conf
Update repositories
sudo apt-get update
Install OpenVPN
sudo apt-get install openvpn
Force the connection to start automatically on boot (optional)
sudo nano /etc/default/openvpn
Find the following line
#AUTOSTART="all"
Uncomment it so it reads as follows
AUTOSTART="all"
Copy the openvpn.conf file to the expected location
sudo cp /path/to/conf/openvpn.conf /etc/openvpn/
You may need to edit this file to tell it where to find your keys if they are not included in the .conf file. This will depend on the server that generated the files.
Restart
sudo reboot
You should now be connected to the OpenVPN server.