sudo apt update
sudo apt upgrade -ysudo apt install openvpn easy-rsa -yCreate a directory for Easy-RSA:
make-cadir ~/openvpn-ca
cd ~/openvpn-caEdit the vars file to customize CA settings:
nano varsUpdate the following lines with your information:
set_var EASYRSA_REQ_COUNTRY "US"
set_var EASYRSA_REQ_PROVINCE "California"
set_var EASYRSA_REQ_CITY "Los Angeles"
set_var EASYRSA_REQ_ORG "MyOrganization"
set_var EASYRSA_REQ_EMAIL "admin@example.com"
set_var EASYRSA_REQ_OU "MyOrganizationalUnit"./easyrsa init-pki
./easyrsa build-ca nopass./easyrsa gen-req server nopass
sudo cp pki/private/server.key /etc/openvpn/./easyrsa sign-req server server
sudo cp pki/issued/server.crt /etc/openvpn/
sudo cp pki/ca.crt /etc/openvpn/./easyrsa gen-dh
sudo cp pki/dh.pem /etc/openvpn/Copy the sample configuration file:
sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
cd /etc/openvpn/
sudo gzip -d server.conf.gzEdit the server configuration file:
sudo nano server.confUncomment or set the following lines:
ca ca.crt
cert server.crt
key server.key # keep secret
dh dh.pem
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"Edit the sysctl configuration:
sudo nano /etc/sysctl.confUncomment this line:
net.ipv4.ip_forward=1Apply changes:
sudo sysctl -psudo systemctl start openvpn@server
sudo systemctl enable openvpn@serversudo ufw allow 1194/udp
sudo ufw allow OpenSSH
sudo ufw enablecd ~/openvpn-ca
./easyrsa gen-req client1 nopass
./easyrsa sign-req client client1
cp pki/private/client1.key /etc/openvpn/
cp pki/issued/client1.crt /etc/openvpn/Create a client config file client1.ovpn:
client
dev tun
proto udp
remote your_server_ip 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
auth SHA256
auth-nocache
verb 3
<ca>
$(cat /etc/openvpn/ca.crt)
</ca>
<cert>
$(cat /etc/openvpn/client1.crt)
</cert>
<key>
$(cat /etc/openvpn/client1.key)
</key>Transfer the client1.ovpn file to your client machine and connect using:
openvpn --config client1.ovpnOpenVPN is now installed and configured on your Ubuntu 20.04 server.
At NexonHost, we believe that everyone deserves to have their services and applications be fast, secure, and always available.
Be the first who gets our daily news and promotions directly on your email.
Copyright © 2025 . All Rights Reserved To NexonHost.