Network client installer

install_openvpn_client_ubuntu.sh

Designed for Ubuntu 20.04, 22.04, and 24.04 LTS hosts that use username/password OpenVPN client authentication and need a repeatable way to install, copy client files, and start the service.

One-liner

curl -fsSL helper.sh/install_openvpn_client_ubuntu.sh | sudo bash
sudo bash install_openvpn_client_ubuntu.sh --source-conf ./client.conf --source-login ./login.txt

Requirements

  • Ubuntu 20.04 / 22.04 / 24.04 LTS
  • root privileges or sudo
  • Optional: client.conf in the current directory
  • Optional: login.txt in the current directory

Best for

  • Bring up an OpenVPN client quickly on a fresh Ubuntu host
  • Standardize username/password client deployment for server handoff
  • Avoid manual file copy mistakes when enabling openvpn-client@client

Highlights

  • Never fails when config files are missing: installs OpenVPN, creates /etc/openvpn/client/, and prompts you to drop the files in
  • Picks up client.conf and login.txt from the current directory, or reuses them if already placed in /etc/openvpn/client/
  • Uses a local update-resolv-conf if present and adds DNS hooks only in that case
  • Enables and restarts openvpn-client@client automatically

Recommended procedure

  1. Optionally put client.conf and login.txt in the current working directory; if you skip this, the script still installs OpenVPN and prepares /etc/openvpn/client/ for you to add them later.
  2. Run the helper.sh installer with sudo or as root.
  3. Let the script install OpenVPN, copy the client files when present, optionally attach a local DNS helper, and restart the OpenVPN client service.
  4. Review systemctl status and ip addr show tun0 to verify the tunnel. If you provided update-resolv-conf, also review cat /etc/resolv.conf.

Safety notes

  • Keep login.txt protected with chmod 600 and do not commit it to Git.
  • Review client.conf carefully before copying it onto a production host.
  • If the service does not start, inspect journalctl before retrying multiple times.
  • If you provide update-resolv-conf, remember that the DNS values are defined inside that helper script.
  • On Ubuntu hosts using systemd-resolved, prefer a resolvectl-aware update-resolv-conf instead of writing /etc/resolv.conf directly.

Scenario article

Install an OpenVPN client on Ubuntu with local client.conf and login.txt checks

A practical guide to using install_openvpn_client_ubuntu.sh to install OpenVPN, verify local client files, optionally copy update-resolv-conf, and enable the openvpn-client@client service on Ubuntu.

Related topics

OpenVPN client access and DNS handling

Set up OpenVPN client access on Ubuntu and CentOS 7 hosts, keep login files in the expected place, and handle DNS switching safely when private domains depend on the tunnel.

Open topic

Problem pages

Why OpenVPN update-resolv-conf is not working

Troubleshoot login files, CRLF script issues, and Ubuntu systemd-resolved behavior when private DNS is expected over OpenVPN.

Open page