Skip to content

OpenVPN from the Command Line (Linux, macOS, Windows)

For headless servers, Raspberry Pis, scripts, or anyone who just prefers a terminal: OpenVPN’s CLI is the same everywhere. One command connects, and the only real differences between systems are how you install the client and whether you run it as a service.

On a desktop?

The native VPNBaron app is the easier path on Windows and macOS, with Baron Pathfinder switching protocols automatically. The CLI shines where apps don’t run.

Setup

  1. Get a config file

    Log in at vpnbaron.com/servers, open the OpenVPN tab and download a config for the server you want: UDP (faster, the default choice) or TCP (firewall-friendly fallback). For a remote machine, download locally and copy it over with scp.

  2. Install the OpenVPN client

    Terminal window
    sudo apt update && sudo apt install openvpn
  3. Connect

    Terminal window
    sudo openvpn --config vpnbaron-server.ovpn

    You’ll be prompted for your VPN username and password: they’re on the same Servers page, top card, and they are separate from your website login. The tunnel is up when the log prints Initialization Sequence Completed. Stop it with Ctrl+C.

  4. Verify

    From a second terminal:

    Terminal window
    curl -s https://buyvpn.com/api/ip

    If the IP shown is the server’s, not yours, you’re tunnelled.

Unattended connections (no password prompt)

Create a credentials file, lock it down, and reference it:

Terminal window
printf '%s\n%s\n' 'your_vpn_username' 'your_vpn_password' | sudo tee /etc/openvpn/vpnbaron-auth.txt
sudo chmod 600 /etc/openvpn/vpnbaron-auth.txt
sudo openvpn --config vpnbaron-server.ovpn --auth-user-pass /etc/openvpn/vpnbaron-auth.txt

Run it as a service (Linux, systemd)

Terminal window
sudo cp vpnbaron-server.ovpn /etc/openvpn/client/vpnbaron.conf
sudo systemctl start openvpn-client@vpnbaron
sudo systemctl enable openvpn-client@vpnbaron # start on boot

Add the auth-user-pass /etc/openvpn/vpnbaron-auth.txt line inside the .conf for a promptless boot. Logs: journalctl -u openvpn-client@vpnbaron -f.

Troubleshooting