OpenVPN Community 2.7 on Ubuntu 26.04 on Azure User Guide
Overview
OpenVPN is the open source SSL/TLS VPN: each person or device holds a certificate signed by your server's own certificate authority, and gets an encrypted tunnel into your Azure network and out to the internet through your VM. This image runs the OpenVPN Community Edition 2.7 from the Ubuntu 26.04 LTS archive as a systemd service on UDP port 1194, with its certificate authority, server key and first client profile made for your VM alone at its first boot. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.
What is included:
- OpenVPN 2.7 (
openvpn2.7.0-1ubuntu1.4) and easy-rsa 3.2.5 from the Ubuntu 26.04 archive, so Ubuntu's security updates and unattended upgrades patch the VPN server with the operating system - OpenVPN run by systemd as
openvpn-server@server.service, as the unprivilegednobodyaccount once started, on UDP port1194 - No key in the image: first boot makes this VM's certificate authority (an EC secp384r1 key), the server's key and certificate, a
tls-cryptkey that protects the control channel, an empty certificate revocation list, and the first client profile/root/client1.ovpn, all on a dedicated 20 GB data disk mounted at/var/lib/openvpn-pki - AES-256-GCM on the data channel, TLS 1.2 at least on the control channel, and the revocation list checked on every connection
- Clients' internet traffic leaves through your VM's own address (full tunnel, with DNS 1.1.1.1 and 9.9.9.9 pushed to them), and the VPN can never reach Azure's instance metadata service or WireServer
openvpn-userto add, revoke and list clients,openvpn-selftestto prove the server end to end from a client in its own network namespace, andcloudimg-set-public-addressto change the address the profiles dial- cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours
Platform: Microsoft Azure, Ubuntu 26.04 LTS (Gen2, x64)
Default user: the administrator user name you choose when you deploy the VM (azureuser in this guide), signing in with your SSH key
Configuration: /etc/openvpn/server/server.conf; keys in /var/lib/openvpn-pki
Prerequisites
An active Azure subscription, an SSH key pair, and an OpenVPN client on each device that will connect: OpenVPN Connect on Windows, macOS, iOS and Android, or the openvpn package on Linux. Standard_B2s (2 vCPU / 4 GiB RAM) is a good starting point for a team; a VPN's throughput grows with the VM size's network bandwidth. NSG inbound: allow 1194/udp from wherever your clients connect (often any address) and 22/tcp from your management network only.
Step 1 - Deploy from the Azure Marketplace
Sign in to the Azure Portal, choose Create a resource, search the Marketplace for OpenVPN Community 2.7 on Ubuntu 26.04 by cloudimg, and select Create. On Basics pick your subscription, resource group, region and size; under Administrator account choose SSH public key and paste your key; under Inbound port rules allow SSH (22). On the Networking tab choose a static public IP address: every client profile dials it, so it must not change. Keep the data disk the image brings: it holds your keys. Then Review + create -> Create. After deployment, add an NSG inbound rule for 1194 over UDP.
Step 2 - Deploy from the Azure CLI
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:openvpn-ubuntu-26-04:default:latest
az vm create \
--resource-group <your-rg> \
--name openvpn \
--image cloudimg1647283583153:openvpn-ubuntu-26-04:default:latest \
--size Standard_B2s \
--admin-username azureuser \
--ssh-key-values ~/.ssh/id_ed25519.pub \
--public-ip-sku Standard \
--public-ip-address-allocation static
az network nsg rule create \
--resource-group <your-rg> \
--nsg-name openvpnNSG \
--name allow-openvpn \
--priority 1010 \
--direction Inbound --access Allow --protocol Udp \
--destination-port-ranges 1194 \
--source-address-prefixes '*'
az vm create names the network security group after the VM (<vm-name>NSG); check its name with az network nsg list --resource-group <your-rg> -o table. Your VM's public address is in az vm show -d --resource-group <your-rg> --name openvpn --query publicIps -o tsv.
Step 3 - Connect to your VM
ssh azureuser@<vm-public-ip>
The login message names your VPN endpoint, the client profile and the commands below.
Step 4 - Confirm OpenVPN is running
First boot started OpenVPN once your VM's keys were made. Check the service, the version, the UDP listener, the tunnel interface and the account OpenVPN runs as:
systemctl is-active openvpn-server@server
openvpn --version | head -1 | cut -c1-60
ss -Hlun | awk '{print $4}' | grep ':1194$'
ip -4 -br addr show tun0
ps -o user=,comm= -C openvpn
active
OpenVPN 2.7.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4
0.0.0.0:1194
tun0 UNKNOWN 10.8.0.1/24
nobody openvpn
The server is 10.8.0.1 on the VPN; clients get addresses from 10.8.0.2 up.

Step 5 - Your server's details and keys
First boot wrote your server's details to a file only root can read:
sudo cat /root/openvpn-credentials.txt
# OpenVPN Community 2.7 VPN server: this VM's details, written on first boot (root only).
# The certificate authority, the server key and the client keys were made on this VM and exist nowhere else.
openvpn.host=<VM address>
openvpn.port=1194/udp
openvpn.vpn.subnet=10.8.0.0/24
openvpn.server.vpn.address=10.8.0.1
openvpn.ca.fingerprint.sha256=4E:AE:A3:C3:80:6D:AB:A1:04:A3:FD:F8:25:5B:3A:28:AB:60:3A:97:7A:C4:63:D1:36:F3:D5:18:47:42:18:2A
openvpn.client.profile=/root/client1.ovpn
#
# Connect: copy /root/client1.ovpn to the client device and open it in an OpenVPN client
# (OpenVPN Connect, or on Linux: sudo openvpn --config client1.ovpn).
# Each profile's 'remote' line is this VM's public address (<VM address>).
#
# One profile per person or device: sudo openvpn-user add <name> (writes /root/<name>.ovpn)
# Cut a client off: sudo openvpn-user revoke <name>
# List clients: sudo openvpn-user list
# Prove the server end to end: sudo openvpn-selftest
# Change the address profiles dial: sudo cloudimg-set-public-address <public-ip-or-dns-name>
#
# User guide: https://www.cloudimg.co.uk/guides/openvpn-community-2-7-on-ubuntu-26-04-azure/
openvpn.host is your VM's public address (shown here as <VM address>), and the fingerprint is your own certificate authority's, so both differ on your VM. The certificate authority is named after your VM and is valid for ten years:
sudo openssl x509 -in /var/lib/openvpn-pki/pki/ca.crt -noout -subject -enddate
subject=CN=cloudimg-openvpn-ca-openvpn
notAfter=Nov 30 12:57:13 2036 GMT

Step 6 - Prove the VPN works
openvpn-selftest connects a real OpenVPN client with client1.ovpn, from its own network namespace on the VM so the traffic truly crosses the tunnel, and checks the handshake, a ping to the server across the tunnel, an HTTPS answer from the internet through your VM's NAT, and that Azure's instance metadata service and WireServer cannot be reached through the VPN:
sudo openvpn-selftest
SELFTEST_OK client1.ovpn connected (AES-256-GCM), VPN address 10.8.0.2; ping 10.8.0.1 OK; internet through the VPN OK (HTTPS 301 from 1.1.1.1); IMDS and WireServer unreachable from the VPN
Any failure prints SELFTEST_FAIL and the step that failed. The test client disconnects when it finishes; your own clients are not touched.

Step 7 - Connect your first device
The profile /root/client1.ovpn is complete: it holds the server's address, the certificate authority, the client's own certificate and private key, and the tls-crypt key, inline, so it is the only file a device needs. Treat it like a password. Its settings (the key blocks are left out here):
sudo grep -vE '^(#|-----|[A-Za-z0-9+/=]{20,}$)' /root/client1.ovpn | grep -v '^$'
client
dev tun
proto udp
remote <VM address> 1194
resolv-retry infinite
nobind
persist-tun
remote-cert-tls server
data-ciphers AES-256-GCM
tls-version-min 1.2
verb 3
<ca>
</ca>
<cert>
</cert>
<key>
</key>
<tls-crypt>
</tls-crypt>
Copy it to your device over SSH. On the VM, put a copy in your home directory:
sudo install -m 600 -o "$USER" /root/client1.ovpn ~/client1.ovpn
On your device, fetch it, then remove the copy from the VM:
scp azureuser@<vm-public-ip>:client1.ovpn .
ssh azureuser@<vm-public-ip> rm client1.ovpn
Then open client1.ovpn in OpenVPN Connect (Import Profile -> Upload File), or on Linux run sudo openvpn --config client1.ovpn. Once connected, your device's traffic leaves through your VM: a "what is my IP" check on the device shows your VM's public address. The server lists the connection within a minute:
sudo openvpn-user list
Step 8 - Add and revoke clients
Give each person or device its own profile, so you can cut one off without touching the others. openvpn-user add issues a client certificate signed by your certificate authority and writes /root/<name>.ovpn:
sudo openvpn-user add laptop-alice
sudo openvpn-user list
client laptop-alice added: /root/laptop-alice.ovpn connects to <VM address> on UDP 1194; copy it to the client device
CLIENT STATUS EXPIRES
client1 valid 2036-11-30
laptop-alice valid 2036-11-30
Connected now (the server updates this every minute):
none
The connected list is the server's status file, rewritten every minute, so a client that disconnected within the last minute (the self-test's, for example) can still show there. Names may use letters, digits, dots, dashes and underscores. To cut a client off, revoke it: its certificate goes on the revocation list, its profile is deleted from the VM, and the server restarts so any session it has open ends at once (your other clients reconnect by themselves within seconds):
sudo openvpn-user revoke laptop-alice
sudo openvpn-user list
client laptop-alice revoked: it can no longer connect (the server restarted to end its session; other clients reconnect by themselves)
CLIENT STATUS EXPIRES
client1 valid 2036-11-30
laptop-alice revoked 2036-11-30
Connected now (the server updates this every minute):
none
A copy of a revoked profile kept anywhere else is refused by the server. Client certificates are valid for ten years, and so is the revocation list openvpn-user writes.

Step 9 - The secure defaults
The server configuration, without comments:
sudo grep -vE '^\s*(#|$)' /etc/openvpn/server/server.conf
port 1194
proto udp
dev tun
topology subnet
ca /var/lib/openvpn-pki/pki/ca.crt
cert /var/lib/openvpn-pki/pki/issued/server.crt
key /var/lib/openvpn-pki/pki/private/server.key
dh none
tls-crypt /var/lib/openvpn-pki/tls-crypt.key
crl-verify /etc/openvpn/server/crl.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/lib/openvpn/ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 1.1.1.1"
push "dhcp-option DNS 9.9.9.9"
data-ciphers AES-256-GCM
tls-version-min 1.2
remote-cert-tls client
keepalive 10 120
user nobody
group nogroup
persist-tun
explicit-exit-notify 1
verb 3
tls-crypt encrypts and authenticates the control channel with a key only your profiles hold, so the server does not even answer a packet without it; dh none uses elliptic-curve key exchange. The firewall (nftables) gives clients internet access through your VM's address, and drops anything from the VPN to Azure's instance metadata service (169.254.169.254) and WireServer (168.63.129.16), so a VPN client can never read your VM's managed identity tokens or settings:
sudo nft list ruleset | grep -E 'masquerade|vpn-no-azure-host' | sed -E 's/counter packets [0-9]+ bytes [0-9]+ //'
ip saddr 10.8.0.0/24 ip daddr { 168.63.129.16, 169.254.169.254 } drop comment "vpn-no-azure-host"
ip saddr 10.8.0.0/24 oifname != "tun0" masquerade
To keep clients' internet traffic on their own connections (split tunnel), delete the push "redirect-gateway def1 bypass-dhcp" line and push a route to your Azure network instead, for example push "route 10.0.0.0 255.255.0.0", then sudo systemctl restart openvpn-server@server.
Step 10 - Changing your VM's address
Every profile dials the address in its remote line. If your VM's public address changes, or you want profiles to dial a DNS name you point at it, set it once:
sudo cloudimg-set-public-address vpn.example.com
It rewrites the remote line of every profile in /root, the details file and the login message; copy the updated profiles to your devices again.
Step 11 - Keeping Ubuntu and OpenVPN up to date
Unattended upgrades are on, so Ubuntu's security updates, including OpenVPN's and OpenSSL's, install by themselves. Run sudo apt update && sudo apt upgrade for everything else, then sudo systemctl restart openvpn-server@server so OpenVPN runs the updated code; clients reconnect by themselves. sudo openvpn-selftest confirms the server works afterwards.
Server components
| Component | Version or setting | Where |
|---|---|---|
| OpenVPN | 2.7.0 (openvpn 2.7.0-1ubuntu1.4, Ubuntu archive) |
/usr/sbin/openvpn |
| easy-rsa | 3.2.5 (easy-rsa 3.2.5-1, Ubuntu archive) |
/usr/share/easy-rsa/ |
| Service | openvpn-server@server.service, enabled, runs as nobody |
/etc/openvpn/server/server.conf |
| VPN endpoint | UDP 1194, routed tun0, VPN subnet 10.8.0.0/24 |
server.conf |
| Keys | EC secp384r1 certificate authority, server and client certificates, tls-crypt key, all made at first boot |
/var/lib/openvpn-pki/ |
| Firewall | nftables: NAT for VPN clients, the VPN kept off Azure host services | /etc/nftables.conf |
| Operating system | Ubuntu 26.04.1 LTS, kernel 7.0 (linux-azure) |
Filesystem layout
| Path | What it holds |
|---|---|
/etc/openvpn/server/server.conf |
The server configuration |
/etc/openvpn/server/crl.pem |
The certificate revocation list the server checks |
/var/lib/openvpn-pki/ |
The 20 GB data disk: pki/ (the certificate authority, every certificate and private key, the issued-certificate index) and tls-crypt.key |
/var/lib/openvpn/ipp.txt |
Which client had which VPN address, so each gets the same one again |
/root/client1.ovpn, /root/<name>.ovpn |
Client profiles (root only) |
/root/openvpn-credentials.txt |
Your server's details (root only) |
/usr/local/sbin/openvpn-user, openvpn-selftest |
Client management and the self-test |
The OS disk is a 30 GB disk with / (28 GB), /boot and /boot/efi; /mnt is the Azure temporary disk, whose contents are lost when the VM is stopped. Back up /var/lib/openvpn-pki (for example with an Azure disk snapshot): without it you cannot issue or revoke certificates for your existing clients.
Managing the service
sudo systemctl status openvpn-server@server
sudo systemctl restart openvpn-server@server
sudo journalctl -u openvpn-server@server -n 50
sudo systemctl stop openvpn-server@server and start stop and start it; disable keeps it stopped across restarts (enable to undo). Connected clients reconnect by themselves after a restart.
On startup
At the first start of your VM, openvpn-firstboot.service runs once:
- It works out your VM's public address, which every client profile dials
- It makes your certificate authority, the server's key and certificate, the
tls-cryptkey and an empty revocation list on the data disk - It enables and starts OpenVPN, writes
/root/client1.ovpn, and proves it with the self-test - It writes
/root/openvpn-credentials.txtand the login message, then/var/lib/cloudimg/openvpn-firstboot.done
What it did is in its journal: sudo journalctl -u openvpn-firstboot. It runs only once (the marker file stops it), so there is nothing to turn off.
Troubleshooting
A client cannot connect: check the NSG allows 1194 over UDP (not TCP) from the client's network, and that the profile's remote line is your VM's current public address (Step 10). sudo journalctl -u openvpn-server@server -n 50 shows each attempt; no line at all means the packets never reached the VM.
"TLS handshake failed" or "tls-crypt unwrap error": the profile is not one this server made (for example, from before a redeploy), or it was revoked. Issue a new one with sudo openvpn-user add <name>.
Connected but no internet on the client: run sudo openvpn-selftest; it names the step that fails. Check sysctl net.ipv4.ip_forward answers 1 and sudo nft list ruleset | grep masquerade shows the NAT rule; if you edited /etc/nftables.conf, sudo systemctl restart nftables.
The service is not running: sudo systemctl status openvpn-server@server and the journal above show why. It needs the data disk: findmnt /var/lib/openvpn-pki should show it mounted.
Security recommendations
- Give every person and device its own profile and revoke a profile as soon as the device is lost or the person leaves
- Open SSH to your own network only, or use Azure Bastion; UDP 1194 is the only port clients need
- Keep client profiles off shared storage: each holds a private key. Delete copies you made on the VM (Step 7)
- Back up the data disk
/var/lib/openvpn-pki, and keep the backup as safe as the keys in it - Keep unattended upgrades on, and run
sudo openvpn-selftestafter any change
Support
cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours, covering deployment, client set-up, split tunnelling and upgrades.
- Email: support@cloudimg.co.uk
- Website: www.cloudimg.co.uk
- Product Catalogue: www.cloudimg.co.uk/products
- User Guides: www.cloudimg.co.uk/guides
OpenVPN is a registered trademark of OpenVPN Inc. cloudimg is not affiliated with or endorsed by OpenVPN Inc. This image ships the open source OpenVPN Community Edition (GPL 2.0), not the proprietary Access Server. All product and company names are trademarks or registered trademarks of their respective holders and are used only to identify the software.