In this article, you will learn how to configure a manual OpenVPN connection on Linux for a non-administrative account. This setup allows a standard user to initiate a secure VPN connection using a script while maintaining system security through specific sudo permissions. These instructions are updated and work for a Ubuntu 24.04 LTS device using the US #10140 server and the UDP protocol.
Before you start:
- A Linux operating system version that is supported by the OpenVPN program.
- Administrative (sudo) access for the initial setup.
- The first 7 steps of the NordVPN Linux manual OpenVPN connection setup tutorial must be completed (OpenVPN packages installed and NordVPN .ovpn server files downloaded).
- Your NordVPN service credentials (found in the Nord Account dashboard).
-
Note: In this guide, we use
myuseras a placeholder for the standard user's account name. Replace it with your actual username. Additionally, you can use older Ubuntu builds than those written in the article; however, we are not able to confirm that it would work.
Here's what to do:
Step 1: Create the connection script
- Log in to your admin account.
- Open the Terminal (Ctrl + Alt + T) and navigate to the Documents folder:
-
Create a new file named
connect-vpn.sh: - Enter the following lines into the editor:
- Save and close the file (Press Ctrl + O, then Enter to save, and Ctrl + X to exit).
- Make the script executable:
cd ~/Documents/
nano connect-vpn.sh
#!/bin/bash
sudo openvpn /etc/openvpn/ovpn_udp/us10140.nordvpn.com.udp.ovpn
chmod +x ~/Documents/connect-vpn.shStep 2: Configure sudo permissions
This step allows the standard user to run the VPN script and the OpenVPN binary without being prompted for an administrative password.
- In the terminal, create a new sudoers policy file:
- Add the following lines to the file, replacing
myuserwith the actual standard username: - Save and exit the editor (Press Ctrl + O, Enter, and then Ctrl + X).
- Validate the syntax and set the required permissions for the policy file:
sudo visudo -f /etc/sudoers.d/nordvpn-user
myuser ALL=(ALL) NOPASSWD: /home/myuser/Documents/connect-vpn.sh
myuser ALL=(ALL) NOPASSWD: /usr/sbin/openvpn
myuser ALL=(ALL) NOPASSWD: /etc/openvpn/ovpn_udp/us10140.nordvpn.com.udp.ovpn
sudo chmod 440 /etc/sudoers.d/nordvpn-user
Step 3: Switch to the standard user account
- Log out of your administrative account or use the user switcher in the top-right corner of the Ubuntu desktop.
- Log in to the Standard User account (
myuser).
Step 4: Connect to the VPN
- Open the Terminal (Ctrl + Alt + T).
- Navigate to the directory containing your script:
- Run the script to establish the connection:
- Enter your NordVPN service credentials when prompted.
- Wait for the connection to be established. You will see the message: Initialization Sequence Completed.
cd ~/Documents
./connect-vpn.sh
Additional tips
-
Server Changes: If you want to connect to a different server, you must update the file path in both the
connect-vpn.shscript and the/etc/sudoers.d/nordvpn-userfile. -
Security: Using a drop-in file in
/etc/sudoers.d/is safer than editing the main sudoers file, as it keeps your custom permissions organized and prevents accidental system-wide lockouts.