A VPN on your VPS gives secure access to the server private network from outside. This guide uses the Ubuntu OpenVPN package as a minimal base.
Steps
Install OpenVPN and easy-rsa:
sudo apt updatesudo apt install -y openvpn easy-rsaEnable IP forwarding:
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-openvpn.confsudo sysctl --systemCopy the sample PKI and build CA/server certs (tune names):
make-cadir ~/openvpn-ca && cd ~/openvpn-ca./easyrsa init-pki./easyrsa build-ca nopass./easyrsa build-server-full server nopass./easyrsa gen-dhCopy certificates to
/etc/openvpn/server, create a basicserver.conf(port 1194/udp, proto udp, dev tun) and start the service:sudo systemctl enable --now openvpn-server@serversudo ufw allow 1194/udp
Tips
- For production, issue clients with
./easyrsa build-client-full NAME nopassand a .ovpn profile. - Prefer restricting SSH and admin panels to the VPN when possible.
ext step
A stable VPS for your VPN: Deploy your Cloud VPS.